ID:144196
 
Code:
for(var/mob/M in world)

switch(input("[Q]?? - by [usr]","Vote in less than 30 seconds!") in list("Option 1","Option 2","Cancel"))

// this gives me the same menu for how many players there are on..which is not what I want. How could I send this to all players?



First you need an if(M.client) which is really important.
for(var/mob/M in world)
if(M.client)
switch(input("Pick") as null|anything in list("option 1","option 2"))
In response to Xx Dark Wizard xX (#1)
the input still doesnt popup for the M's
In response to Morf (#2)
for(var/mob/M in world)
if(M.client)
switch(input(M,"Pick") as null|anything in list("option 1","option 2"))
In response to A.T.H.K (#3)
Ah, I forgot to put the M in, try ATHK's example it should work and use as null|anything instead of the cancel option.
In response to Xx Dark Wizard xX (#4)
Yes, ATHK got it right. input() has an optional first argument which is the player that gets the input box - by default, it's usr, so you need to specify it in cases like this.

Also, I don't think checking if the client is valid is very important in this case, as input() should just terminate with no input box generated and return null, which isn't exactly fatal. :)
In response to Kaioken (#5)
Plus, you should probably be looping through all clients rather then all mobs. Duh.
In response to Kaioken (#5)
Kaioken wrote:
Yes, ATHK got it right. input() has an optional first argument which is the player that gets the input box - by default, it's usr, so you need to specify it in cases like this.

Also, I don't think checking if the client is valid is very important in this case, as input() should just terminate with no input box generated and return null, which isn't exactly fatal. :)

If you try to send input() or alert() to a clientless mob, you'll get a "bad client" error. However, this is easily avoided if you loop through all clients in the world, not all mobs in the world.

Of course, one additional consideration is that input() will wait for a response, so you'll need to spawn() out each call to it.

Lummox JR