ID:263055
 
Code:
area/GM
Entered(mob/M)
if(M.AdminXX2 == 0)
alert("Only GMs are aloweed to enter")
return 1


Problem description:Normal players can enter =/.

mob
Bump(area/GM/gm)
..()
if(istype(gm,/area/GM/))
if(!M.AdminXX2)
alert("Only GMs are aloweed to enter")
return FALSE
else if(M.AdminXX2)
M.density = 0
M.Move(gm.loc, M.dir)
M.density = 1
return TRUE


This is Untested.
In response to Y2kEric
And inefficient.
turf/Enter(mob/m)
if(!ismob(m))return
if(!m.admin) //I recommend a list, if(!m.ckey in admins)
m<<"Access denied."
return 0
return ..()
In response to Hell Ramen
=O thanks...
return 0 then return..()?thanks again =D
In response to Hell Ramen
Hell Ramen wrote:
And inefficient.
> turf/Enter(mob/m)
> if(!ismob(m))return
> if(!m.admin) //I recommend a list, if(!m.ckey in admins)
> m<<"Access denied."
> return 0
> return ..()


if(!(m.ckey in admins)) =P
In response to Justin B
Heey, you try programming on a minicomputer!

Tough work, I tell you. Just typing is hard. =(
The problem, which apparently hasn't been explicitly pointed out, is that you used Entered() instead of Enter(). When a mob moves, here's the progression:
  1. does mob.Move() succeed?
  2. does turf.Enter() succeed?
  3. execute the move
  4. execute turf.Entered()

So, as you can see, you were checking to see whether they were a GM after the mob had already moved into the area. In the help given, Enter() was correctly used instead of Entered(). Hopefully, you won't have to make the mistake again. Just remember to apply the tense: you have Entered after you Enter.
In response to Pharaoh Atem
return ..() returns to the parent procedure(in this case, Enter) and calls it. Without that, You wouldn't move at all.

return 0, in short, does a stop-halt on the procedure where it's at.
In response to SSJ2GohanDBGT
This is actually really simple stop being show-offs -_-

turf/GM
Enter()
if(usr.client)
if(usr.gm)
..()
else
usr << "<b>You are not a GM!"
return
else
return
In response to Chrisman767
Who was showing off? =P He asked a question and I answered it.

By the way, Hell Ramen's way was already stated and is much more efficient.
In response to SSJ2GohanDBGT
I suppose just because its smaller >.> But both would do the same thing, I didn't really think while making that.
In response to Chrisman767
There's no place for usr in Enter(), that else return statement is unnecessary, you didn't return 0 if access is denied, and you didn't return ..() if access is granted.
In response to Artemio
Actually, I avoid returning to the parent because if the turf's density is one, you're still screwed. Though, you/we/whoever may know this, and fix it, but some people'll look over that and re-ask the question.
In response to Chrisman767
Chrisman767 wrote:
This is actually really simple stop being show-offs -_-

> turf/GM
> Enter()
> if(usr.client)
> if(usr.gm)
> ..()
> else
> usr << "<b>You are not a GM!"
> return
> else
> return
>



Yuck!
In response to XzDoG
XzDoG wrote:
Yuck!

It's not yuck! It's very nice, and it would be just about perfect with a few minor tweaks.

area/GM_only/Enter(mob/m)
if(istype(m) && m.gm) . = ..(m)
else . = 0


Edit: I screwed that up. It ought to be better now... just incase anybody was looking at it.
In response to Mysame
That makes no sense. Returning 1/TRUE would signify that regardless of the turf's density you could enter it if gm is true, however checking to see if gm is true then, if so, returning the parent would mean that it checks if the turf is enterable.
In response to PirateHead
PirateHead wrote:
The problem, which apparently hasn't been explicitly pointed out, is that you used Entered() instead of Enter(). When a mob moves, here's the progression:
  1. does mob.Move() succeed?
  2. does turf.Enter() succeed?
  3. execute the move
  4. execute turf.Entered()


Not to nitpick, but I believe turf/Exit() and Exited() come before Enter() and Entered() of the next turf. I'm unsure where they are in respect to Move(), however.
In response to PirateHead
PirateHead's got a point.

PH. Dude. You know a LOT about coding. You know how to fix every single coding problem existed in BYOND. How do you know so much coding things? It's... just amazing. your posts are the perfect answers for everyody.