ID:985017
 
(See the best response by LordAndrew.)
Code:
turf
Nomonsterpass
Entered(O)
if(istype(usr,/mob/enemies))
return 1
else
return 0


Problem description:
Hi everyone,

I am trying to create a turf wich players and/or npc's can walk threw but monsters cant. For example i made a town and at the entrance of this town i want to place these turfs so monsters cant walk in. Now i came up so far with the code above but the only problem is my monsters just walk threw it everything can actually so i was wondering if someone could help me out with this one?

Greetings,

Chaokai
Best response
A few things of note: You should be using Enter() instead of Entered(). Enter() initially determines if something can even step on a tile in the first place, while Entered() is an event fired after Enter() is called.

Secondly, usr isn't safe to use in Enter[ed]() as usr isn't always going to be what you expect.

Finally, return 1 would allow anything to pass, regardless of the tile's density or if something else is occupying it.

turf
Enter(mob/m)
if(istype(m, /mob/enemies)) return FALSE

return ..()
Thank you very much for your quick respond, i fixed it and i now understand more about the enter[ed] commands.