ID:158621
 
How do i send a switch to a mob by using a verb for example :
mob
verb
Talk(mob/M as mob in get_step(usr,dir))
for(M)
switch(alert("Do you want to talk to [usr]?",,"Yes","No"))
if("Yes")
..()
if("No")
..()

(This code will send you a switch and will ask continuously)
Why are you using the for() there? And why are you asking usr if (s)he wants to talk to him/herself?

And you can use a simple if-else for that:
if("Yes" == alert(src,"Do you want to talk to [M.name]?",,"Yes","No"))
...
else
...
In response to GhostAnime
No,you got me wrong I'm trying to send a switch to the mob in front of me.But instead it asks me.
In response to Destrojer
Then make it ask M, look up the input() procedure in the DM reference (or switch src and M in the snippet I have shown).
In response to Destrojer
switch() is a control statement, like if(). You want to send an alert() to another mob. Look it up in the reference, it says right there.
Lately I've been noticing a lot of people confuse the switch() proc to be the one showing an options popup. If you actually read the reference instead of using it without knowing about it(most likely due to seeing it in a source or a demo), you'd see it doesn't do anything special for alert() and input() rather than any other value.

var/random = rand(1,10)
switch(random)
if(1,3,5,7,9) src << "It's odd!"
if(2,4,6,8,10)src << "It's even!"

var/through = rand(1,50)
switch(random)
if(1 to 25) src << "First half!"
if(26 to 50)src << "Second half!"

Bad example really, since it could simply be achieved with an if/else, but that's what switches are. They are condensed if/else-if chains that compare things to constant values.

The alert() and input() procs just return a value.
var/result = input("blah")in list(1,2,3,4,5)
src << "You chose [result]!"
if(result == 5)src << "You are special!"
if(result > 5)src << "Wtf hax0rz!?"

var/button = alert("click one!","awesome title","moo","baa","cheep")
src << "You chose [button]!"
switch(button)
if("moo")src<<"Cow!"
if("baa")src<<"Sheep!"
if("cheep")src<<"Chick!"


Rather than using switch() for an alert() with only two options, just use a simple if() statement, like Ghost showed.
In response to Kaiochao
It's ok,it's ok....i managed to get it to work....thx ^^