ID:148261
 
i was wondering wuts the easiest way to make a admin door.

i thought mabey using like if (usr.admin = 1) or somethign and put in my admin code usr.admin == 1 so it be

if (usr.admin ==1)
density = 0
else
density = 1
usr << "Only admins are allowed in here!" thx
You have the right kind of idea,
check out my door demo, It shows you a couple different ways you can do doors.
In response to Nick231
one problem here if(istype(usr,/mob/player) i cna change that so that people cna be allowd in but i have 4 classes id have to make 4 copies of that code unless theres a quicker way
Vegeta54367 wrote:
i was wondering wuts the easiest way to make a admin door.

i thought mabey using like if (usr.admin = 1) or somethign and put in my admin code usr.admin == 1 so it be

if (usr.admin ==1)
density = 0
else
density = 1
usr << "Only admins are allowed in here!" thx

You're doing two things wrong here: First, you're using density changes instead of Enter(); if you use Enter(), you can return 0 to disallow entry or ..() (the default proc) to act normally for admins. The other thing you're doing wrong is that you're using usr somewhere that you clearly shouldn't be.

Lummox JR
In response to Lummox JR
why cant i use usr.admin it works most times doing that
In response to Lummox JR
and what would you suggest somehting like

turf
admindoor
if (usr.admin == 1)use what instead of this
Enter()
else
Enter() return 0 ????
In response to Vegeta54367
Actually, more around these terms:

turf
door
Enter(atom/movable/A)
var/mob/M=A
if(M.client)
if(M.admin)
return 1
else
return 0
In response to Vegeta54367
Vegeta54367 wrote:
why cant i use usr.admin it works most times doing that

http://www.byondscape.com/ascape.dmb/LummoxJR.2002-1104/
In response to Goku72
Goku72 wrote:
Actually, more around these terms:
turf
door
Enter(atom/movable/A)
var/mob/M=A
if(M.client)
if(M.admin)
return 1
else
return 0

That's close, but there are three problems:

  • A might be an obj, not a mob. An obj doesn't have the client var, and will result in a runtime error. You should use ismob() to be sure. It's safe to put that right in the if(), so you have if(ismob(M) && M.client) instead.
  • Returning 1 will skip over the density check, so if another mob is standing in the door, you can walk right through them. Typically it's more desirable to return ..() instead, which will return the default value, and 0 to deny access completely.
  • You have no fall-through default case for objs or non-player mobs, so it essentially ends up returning 0 (actually null, but same difference). This might be the desired behavior, but it doesn't hurt to say so explicitly. More often I think it'd be preferred to return ..() to allow objs and NPCs to pass special doors. Here I could see maybe letting an obj through but not an NPC.

    Lummox JR
In response to Vegeta54367
If you are having trouble, just change it to
mob/turf
admin_door
icon = 'door.dmi'
icon_state = "admindoor"
if (usr.key == "Vegeta54367")
src loc = locate(1,1,2)//make a new z lvl for this
usr << "You are admin/gm. you are aloud in here
else
srcloc = loacte (1,1,1)
usr << "muahahahahaa you aren't admin you have to start over!"


That might work. I dunno :-)

~STARWARSPOWER~

In response to Starwarspower
Stop answering this question! It's ALREADY BEEN ANSWERED. ([link]) Read before you post.
In response to Crispy
Crispy he's aloud too.
In response to Maz
Two people so far have answered this thread, even though Lummox has already dealt with it. It's annoying. =P

Plus, the code both of those people have posted is WRONG. Neither will work, for different reasons. Starwarspowers', in particular, is utterly ridiculous. An if() outside a proc? And what the hell do you think "usr 1,1,2" will do? It'll cause a compiler error (or, more likely, several), that's all. It's dangerous to post that kind of code; newbies might see it and think that it's proper code, leading to more work for us Newbie-Central-answerer-people.
In response to Starwarspower
Swp, kindly refrain from posting completely bogus code in response to a question. What you posted is wrong on so many levels there's no point in even debugging it with you. It helps no one when you do that, and can only hurt. I don't want to discourage you from helping, but be sure that you're actually helping when you do.

Lummox JR
In response to Crispy
actually even if it did work youd never be able to get out lol seeing as how is 1,1,2 so youd just be sent to the same place over and over again.....i got the door done and it works now thank you to all who posted here it was a big help.One question cause i forget wut is the code to direct your game when you host it to the file on byond goes after name ="blahblah"

i had it but now i forget it thx