mob/verb/Vote()
var/Yes=0
for(var/mob/P in Players)
spawn if(P)
switch(input(P,"Do you want pizza?") in list("Yes","No"))
if("Yes") Yes+=1
spawn(100) world<<"There were [Yes] 'Yes' answers"
Ok so this is just an example not my real code but it still reproduces the problem.
It is supposed to pass a prompt to all players and they vote if they like pizza. Then 10 seconds later the answer is output.
The problem is, no matter how many people click yes, it always says the answer is 0. It says the Yes=0 at the end even when many people chose Yes as the answer.
This is not a problem with the Players list, people ARE getting the prompts, and they are choosing their answer before the spawn(100) is completed.
if I replace the spawn(100) with sleep(100) the result is still the same so that is not it either.
Help is appreciated.
Even without the prompt like below it STILL says 0.
mob/verb/Vote()
var/Yes=0
for(var/mob/P)
spawn if(P)
Yes+=1
spawn(30) world<<"There were [Yes] 'Yes' answers"
I can't find any libraries for voting systems either.
Try making the var/Yes a global (by moving it outside of the block). That's a bit hacky but it should fix your problem.