ID:176336
 
how can i make it so that when you go up 6 or less tiles to a mob you start to here sound and when you step away from the mob it stops playing
mob.Move()//When they move
        for(var/mob/M in view(5)) //for every player in the view.
                if(!M) //if there is no mob in view.
                        src <<sound(null) //make them hear nothing.
                        return ..() //move and do everything like normal
                else //if there is a mob!
                        src <<sound("Sound",1) //play the sound
                        return ..() //move and do everything like normal

I think.

- Siientx


In response to Siientx
Siientx wrote:
mob.Move()//When they move
for(var/mob/M in view(5)) //for every player in the view.
if(!M) //if there is no mob in view.
src <<sound(null) //make them hear nothing.
return ..() //move and do everything like normal
else //if there is a mob!
src <<sound("Sound",1) //play the sound
return ..() //move and do everything like normal

Problem: This'll start a new sound every time. You really should use a var to keep track of whether a sound is already playing, so you don't end up constantly replaying it.

Lummox JR
In response to Siientx
Siientx wrote:
mob.Move()//When they move
for(var/mob/M in view(5)) //for every player in the view.if(!M) //if there is no mob in view.src <<sound(null) //make them hear nothing.return ..() //move and do everything like normalelse //if there is a mob!src <<sound("Sound",1) //play the soundreturn ..() //move and do everything like normal
!M will never evaluate to true if you're looping on mobs, and assigning them to M! If there are no mobs, the loops simply doesn't execute.