ID:171544
 
how would i prevent people from entering a certain area in my game?

i.e. in a few games ive played there are houses and the like where only one person (the owner) can enter

any suggestions at all would be really helpful

thank you
you could check the obj/turf that the mob bumps(the bump() proc)

when you bump, check if the turf is a door turf. if it is, chekc if you are the owner of the door(for the door turf add a var called owner that holds the owners name)

this would be my guess.
In response to Jik
thank you very much

ive tried using entered() but it checks after you actually enter the space which isnt good...

In response to GunRunner
arrrrrrrrrgggggggggg i still cant get it to work dag nammit
In response to GunRunner
ok, try this then.

mob
Move()
var/turf/T = get_step(src,src.dir) //this will check the turf before you step on it
if(istype(T, /turf/door/) && T.owner != src.name) //or how ever you determine who owns the house
src << "Not your house"
return //end movement without moving
else
..() //continue the standard move


This adjustment to the Move() proc should stop a person if they try to walk over a door that they do not own. This only works if the doors have density of 0. if you want the doors to have a density of 1 then you would have to alter the if like this:

if(istype(T, /turf/door/))
if (T.owner != src.name)
src << "not your house"
return //end movement without moving
else //it is your house
new /turf/door/open(T)//make it now passable
..()
else
..()


I'm no master but that's off the top of my head. If you don't want to change the turf (so no one else can follow) then you would have to find a way of making the mob move 2 spaces ahead on where he is (with src.loc = locate(x,y,z)) but that would depend on which what he/she was facing...

Hope this gets you going...
In response to Jik
thank you


muchly appreciated
In response to GunRunner
GunRunner wrote:
thank you


muchly appreciated

No problem. One of my long term projects may have to use the same kind of methods. So in helping you, I'm helping me!

(That's why I read through this section alot)
The advice you've recieved is completely wrong, because it completely ignores the proc specifically designed for this.
turf
privateDoor
var/owner = "Garthor"
Enter(atom/movable/A) //Called when something tries to enter
if(ismob(A))
var/mob/M = A
if(M.name == owner)
//You may wish to check key instead, for more security
return 1 //Allow access, no matter what.
else
return 0 //Disallow access, no matter what.
else
//It's not a mob
return ..()
//We'll allow it access, if it'd be allowed access anyway
//Thus, objs can enter if the door isn't dense
//and nobody is standing in it.


Also note that Enter() should not actually do anything on its own. Move() calls Enter() up and asks "Hey, can I come over to your place?" Enter then returns 0 to say, "No, man, my parents are home," returns 1 to say, "Oh, of course! Come on over!" or returns ..() to say, "Sure, if my door's unlocked."
In response to Garthor
Like I said, I'm no master... =$