ID:262899
 
obj/hud 
Yell
layer = MOB_LAYER+21
name = "Yell"
icon = 'Tiles.dmi'
icon_state = "yell"
screen_loc = "5,13"
Click()
var/say = input("Type what you want to yell here.","Yell")as null|text
say = copytext(say,1,200)
if(usr.talked == 1)
alert("You must wait 2 seconds between sentences")
else if(!say)
return
else
for (var/mob/M in world)
if (!M.NoHear.Find(usr))
M << "<font color = red><font size= -1><b>[html_encode(filter(usr.char_name))] Yells:</b></font><b><font color = maroon><font size= -1> [html_encode(filter(say))]"
usr.talked = 1
sleep(15)
usr.talked = 0


For some wierd reason its running the sleep() proc before it's called, then saying the input.

mob/loginverbs/verb/Say(say as text)
set category = null
say = copytext(say,1,200)
if(usr.talked == 1)
alert("You must wait 2 seconds between sentences")
else if(!say)
return
else
for (var/mob/M in view(6))
if (!M.NoHear.Find(usr))
M << "<font color = Blue>[html_encode(filter(usr.char_name))] Says, <font color = aqua>[html_encode(filter(say))]"
usr.talked = 1
sleep(15)
usr.talked = 0


This is my say code, yet this one works fine.


Could it be just because its an object?
For Boolean variables (ones that can only be 1 or 0), don't do if(var==1) and if(var==0). Do if(var) and if(!var). For example, look at if(usr.talked==1).

Don't use if(list.Find(whatever)) in order to see if something is in a list. Use if(whatever in list). The reason is that in the list is empty, you'll get a runtime error.

As for your problem, this is what your code is doing:

Create a loop going through all mobs in the world.
First mob found.
Tell him the message.
sleep(15)
Second mob found.
Tell him the message.
sleep(15)
Third mob found.
Tell him the message.
sleep(15)
Etc.

See where it's going wrong?
In response to DeathAwaitsU
Not to mention he's also setting/resetting talked=1/talked=0 for each mob the message goes out to, those need to be put outside of the for() statement.
In response to Detnom
Detnom wrote:
Not to mention he's also setting/resetting talked=1/talked=0 for each mob the message goes out to, those need to be put outside of the for() statement.

...thats pretty much what DeathAwaitsU was trying to say.
In response to FranquiBoy
Never hurts to explain a little further, though. =P