ID:271000
 
How do you make an area, turf, or obj that only people with a certain var can cross, with it being in the same Z and being able to be reached by everyone, but not be passed by everyone.
For turfs and areas:

Use Enter()

Look up Enter(), Entered(), Exit(), and Exited()...

Note on areas: Once you successfully enter one and do not exit, if the variable that allows/disallows access changes, you can still move around that area. (assuming the area you want to use will take up multiple tiles)Once you exit though, the variable will be checked again.


For objs:

Use mob/Bump()

Have the var checkerand step operation there.


You, my fellow BYONDian, want Enter().

Now, Enter(), along with other movement procs need something VERY important: SAFETY CHECK!!! If you put mob/M or somehting similar in the argument [Enter(mob/M)], it will NOT LOOK FOR THAT PATH... meaning it will classify even an obj as M, so use ismob()/istype()/etc. Oh, and IT MUST NEVER use 'usr'!!


More info: http://www.byond.com/docs/guide/chap07.html [Section 1]


- GhostAnime
In response to GhostAnime
I tried it, but I can still go through it even with the certain var.
turf/Mirror/Enter(mob/person/M)  //This will NOT look for mob/person
if(!ismob(M)) del M //if it is not a mob, it is deleted (it = object trying to enter)

if(!istype(M)) return //If it is not mob/person, it stops M from entering
if(!M.Mirror_Breaker) return 0 //If the person does not have that value set as TRUE, it won't let M enter.
return 1 //allows all else to enter


- GhostAnime
In response to GhostAnime
I can still go through even with the var.
turf/ANBLOCKER/Enter(mob/M)  //This will NOT look for mob/person
if(!istype(M)) return //If it is not mob/person, it stops M from entering
if(M.HBequipped==1) return 0 //If the person does not have that value set as TRUE, it won't let M enter.
return 1 //allows all else to enter
turf/ANBLOCKER/Enter(mob/M)  //This will NOT look for mob/person
if(!istype(M)) return 0 //If it is not mob/person, it stops M from entering
if(!M.HBequipped) return 0 //This check was the wrong way around
return ..() //Return 1 will let people walk through other people on that tile. ..() means 'do the default procedure stuff'
In response to Jp
I can still go through.
Anyone going to help me? >.<
You do realize that you only waited 2 hours and that everyone is not always online and have lives in which they need to attend.

"Patience is a virtue" - Somebody annoyed by the impatience of others
In response to KirbyAllStar
Ditto Kirby.

SPM, show us your latest snippet please.

- GhostAnime
In response to GhostAnime
///////////////////////
////LATEST//SNIPPET////
///////////////////////

area/ANBLOCKER/Enter(mob/M) //This will NOT look for mob/person
if(!istype(M)) return 0 //If it is not mob/person, it stops M from entering
if(!M.HBequipped) return 0 //This check was the wrong way around
return ..() //Return 1 will let people walk through other people on that tile. ..() means 'do the default procedure stuff'


~ Madjarjarbinks

EDIT: I know that it's setting the var right for the mob.
Super Mario Productions wrote:
> ///////////////////////
> ////LATEST//SNIPPET////
> ///////////////////////
>
> area/ANBLOCKER/Enter(mob/M) //This will NOT look for mob/person
> if(!istype(M)) return 0 //If it is not mob/person, it stops M from entering
> if(!M.HBequipped) return 0 //This check was the wrong way around
> return ..() //Return 1 will let people walk through other people on that tile. ..() means 'do the default procedure stuff'
>

~ Madjarjarbinks

EDIT: I know that it's setting the var right for the mob.
area/ANBLOCKER/Enter(mob/M)
if(ismob(M))
if(M.HBequipped)
return 1
In response to Bobthehobo
Bob, you have it completely in reverse... -.-
So you want H.Bequipped to be false?

area/ANBLOCKER/Enter(mob/M)
if(ismob(M))
if(!M.HBequipped)
return 0
else
return 1
In response to Bobthehobo
No no no no no! return 0 and return ..()!

You don't want people being able to walk over anything on that space!
In response to Jp
Thanks for the help, guys.