ID:1695533
 
(See the best response by Pokemonred200.)
Code:
if(src.loc==(src.x<=78 && src.x>=53 && src.y<=199 && src.y>=185 && src.z==2))
src.loc=locate(/turf/trainingteleports/backtogym)


Problem description:Ok so I have a area of the game that's made so only 1 person can go in for a set amount of time. Well what's happening is that people currently go into the room, relog, and stay in the room infinitely, or even have multiple people able to go in. What i'm trying to make happen is when people log in, and are inside the room, will get re-located outside the room. if someone could either help me get the code above correct, that would be awesome. If it happens to be correct.. possibly i have the code in the incorrect spot.

if(src.loc == locate(x, y, z))

Compare your current location to the location you want to check.
ok so then something more along the lines of:
    if(src.loc==locate(65, 190, 3))
src.loc=locate(/turf/trainingteleports/backtogym)


unfortunately i couldn't get that to work :/ no errors, just nothing happens when i log in.
thinking my error might lie somewhere else, how would i check a whole area? for example..
if(src.loc==locate(1-200, 1-200, 1-10))
src.loc=locate(/turf/thatplace/overhere)
When you're checking if you're on that turf have you actually loaded your savefile first?
I did have a realization that I should check that out in the Load() section of the code so this is kinda what i found/came up with
    Load()
var/savefile/F = new("Player Saves/[src.mob.key].sav")
F["Mob"] >> src.mob//This is unneccary
F["last_x"] >> src.mob.x
F["last_y"] >> src.mob.y
F["last_z"] >> src.mob.z
if(src.mob.x >= 0)
usr.loc=locate(/turf/trainingteleports/backtogym)

but this is still not doing anything for me :/ I put x >= 0 because i would think it would happen without fail but.. nothing.

*Edit* nevermind i'm an idiot, should have been
 src.mob.loc=locate(/truf/trainingteleports/backtogym)
In response to Sempaialexeo
Best response
Sempaialexeo wrote:
I did have a realization that I should check that out in the Load() section of the code so this is kinda what i found/came up with
>   Load()
> var/savefile/F = new("Player Saves/[src.mob.key].sav")
> F["Mob"] >> src.mob//This is unneccary
> F["last_x"] >> src.mob.x
> F["last_y"] >> src.mob.y
> F["last_z"] >> src.mob.z
> if(src.mob.x >= 0)
> usr.loc=locate(/turf/trainingteleports/backtogym)

but this is still not doing anything for me :/ I put x >= 0 because i would think it would happen without fail but.. nothing.

*Edit* nevermind i'm an idiot, should have been
 src.mob.loc=locate(/truf/trainingteleports/backtogym)


Frankly,
F["last_x"] >> src.mob.x
F["last_y"] >> src.mob.y
F["last_z"] >> src.mob.z


isn't really a good practice because of how x, y, and z work; You should use something like

src.mob.loc = locate(F["last_x"],F["last_y"],F["last_z"])


instead. Just my two cents on the matter, though.
I see, thanks that actually does work well... So then I have to ask, is there a more proper way to do the save portion?? ?
Save()
if(src.atlogin)
return
var/savefile/F = new("Player Saves/[src.mob.key].sav")
F["Mob"] << src.mob
F["last_x"] << src.mob.x
F["last_y"] << src.mob.y
F["last_z"] << src.mob.z