-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task_set_result resulting 0? #8
Comments
You can call |
|
|
Yes it does, but I still should be able to use |
This behaviour is intended; you should not be able to access the task once is has completed. Notice that your code doesn't delete the task at all, which is fine, since it gets deleted automatically at the point of Tasks are used to resume paused code; there is usually not much point in keeping the task alive after code that wanted to handle it ended. As I said, if you want to use tasks in a non-standard way (i.e. keeping it alive after its completion or just for storing a value), there is new Task:t = task_new();
task_keep(t);
task_set_result(t, 1);
...
task_delete(t); |
Ahh, I still believe I found a bug in that case which is the reason I got confused, because task_get_result did return 4 (the value I needed) when characters had multiple factions (meaning they would go through the dialog and once they selected their faction from the dialog the task_await code would continue) even though I had no task_keep on at that time. It's clear now, thanks for your help. |
In that case, the task will be available immediately in the continuation (i.e. after |
So, what's the difference between |
A call to In the first case, the order of operations is 1) In the second case, Using Also note that new memberSelected = task_awaitPlayerInfo[playerid][pAwaitMembershipSelection]); |
Oh damn, thank you for your help, it's been really helpful to me. It seems like there's no way to call |
I still think not creating a task when not needed is the best option, but to address your case, I have modified |
Hey there. I changed my old code a bit, in the old code I stored the ID in a seperate variable, now I instead pass the ID over task_set_result.
https://pastebin.com/pb4YWxGQ
When someone does the /badge command, it executes the SelectPlayerFaction function, which then checks how many factions the player is a member of. If there's only one faction, it should set the ID of that faction as the result. It does set a result, but for some reason it always sends back 0 to the command. I also printed out the value of Iter_First and it does print out the currect value. What is also odd, is that when a player is a member of multiple factions and he goes through the dialog and selects a faction, it does somehow work.
I've tried everything, there's no errors, warnings or anything strange in any of the logs. This is also all of my code in regards to the PlayerInfo[playerid][pAwaitMembershipSelection] task, so it's not being reset or something in the background. I even reverted back to the old style where I stored the information in a seperate variable, and that doesn't work either, leading me to think it has something to do with the "case 1" part I added inbetween, but there's nothing wrong there, so I'm legitimately confused.
The text was updated successfully, but these errors were encountered: