ID:262092
 
How do I make this no monster enter barrier thingy not delete the monsters? When a monster chases me and I run outside thr barrier, the monster vanishes when it runs into the barrier. How do i make it where the monster just stays inside of it instead of vanishing? Here is the code:

area
NoMonsterEnter1
Entered(mob/M)
if(M.client)
usr<<""
else
M.loc = locate(14,7,1)
area
NoMonsterEnter1
Enter(A)
var/mob/M = A
if(!M.client) return
Its not vanishing, its being teleported to co-ordinates(14,7,1)

If you want it to stay at its current location then after the else you could put a return command or do M.loc=M.loc
In response to SSJ2GohanDBGT
thanx, i think i'll try it now
In response to SSJ2GohanDBGT
SSJ2GohanDBGT wrote:
> area
> NoMonsterEnter1
> Entered(A)
> var/mob/M = A
> if(!M.client) return
>


um, now they're chasing after me outside the barrier....
In response to DeathAwaitsU
DeathAwaitsU wrote:
Its not vanishing, its being teleported to co-ordinates(15,17,1)

If you want it to stay at its current location then after the else you could put a return command or do M.loc=M.loc

um.same thing, didnt work
In response to Mecha Destroyer JD
What type paths are the mobs, and honestly that doesn't make sense. Also, I edited the post. Try Enter() instead of Entered(). I do believe Entered() happens after its done.
In response to SSJ2GohanDBGT
Ok, it does its job blockign. But its blocking me out too. Is there a way to block just the monsters and not me?
In response to Mecha Destroyer JD
Thats because your the host, and you don't technically have a client(address, anyhow). Just add a check in it.
In response to SSJ2GohanDBGT
SSJ2GohanDBGT wrote:
area
NoMonsterEnter1
Enter(A)
var/mob/M = A
if(!M.client) return

Two problems:

  • You can't assume A is a mob; it may also be an obj in this case. Always check first.
  • You need to return ..() for objs and players.

    Lummox JR
In response to Lummox JR
Heheh, oops. Thanks for catching my mistake. Care to explain why you need the ..() for players or mobs?
In response to SSJ2GohanDBGT
SSJ2GohanDBGT wrote:
Heheh, oops. Thanks for catching my mistake. Care to explain why you need the ..() for players or mobs?

Because Enter() is expected to return a value. If you don't give it one, the return value is automatically null, which is interpreted as false: That is, allow no entry. Calling ..() and returning its value will send back the default value of Enter(), so for non-monsters this is the way to go. Without calling that, your code would always return null no matter what, so nothing could get in.

Lummox JR