ID:144639
 
Code:
    kageIN
icon = 'mansions.dmi'
icon_state = "kagedoor"
density = 1
opacity = 1
Enter()
if(usr.rank == "Hokage"||"Raikage"||"Mizukage"||"Kazekage"||"Tsuchikage")
return 1
usr << "You may pass."
else
usr << "You must be Kage level to enter."


Problem description: Whats wrong with this? It isnt supposed to let everyone in, but it does...

It's because you utterly destroyed the code block by not having any arguments nor safety check in the Enter() proc and having usr abuse in the said proc :(

Enter() and it's family, including its' twice-removed cousin Bump(), do not automatically check for what you define in it's argument.

Wondering what I mean? Let's see an example:
turf/something/Enter(mob/M)


Now, you would assume that this procs is called when a mob enter the turf's contents (location)? Wrong. If an object entered the turf, it would still call the Enter() despite you defining the argument as a mob.

Solution 1: Use SAFETY CHECKS (Murphy's Law people, remember about it!)!!! And use the argument of Enter() instead of usr.

As for why using usr is evil in Enter() and it's family is because the procedures are automatically called via atom/movable/Move(), not by anything directly from the player(s).

- GhostAnime

Edit: And see UP's post, I can't believe that I missed that little thing >_<

Edit2: That code looks suspiously like the kageIn turf of the old WOTS source code... or it could be just me <font size=1>Psh, yeah right</font> >_>
Ynohtna wrote:
Code:
>   kageIN
> icon = 'mansions.dmi'
> icon_state = "kagedoor"
> density = 1
> opacity = 1
> Enter()
> if(usr.rank == "Hokage"||"Raikage"||"Mizukage"||"Kazekage"||"Tsuchikage")
> return 1
> usr << "You may pass."
> else
> usr << "You must be Kage level to enter."
>


I have no clue where everyone is getting this code, because I've probably seen this snippet more than 5 times already. If the code is taken from another Naruto game, I highly suggest you to trash it, and start over again. It will benefit you a lot.

The main problem is that you're checking if usr's rank is "Hokage", then checking if the other conditions are true, which are always true. You have to compare the player's rank seperatly. Another problem is that you are relying on usr to figure out who entered the object, which isn't always correct. You also assume usr is a mob, and you can watch your code crash when a freeflying object hits it. In addition to that, you're returning before you display "You may pass" to the player, therefore, they never get notified.

~~> Unknown Person
In response to GhostAnime
Well, you also forgot to point out the problem with his if statement.
mob/proc/yea()
if(src.key == "Popisfizzy"||"The Fizz Meister"||"The Fizz") world << "Looks, it [src.name]"
else world << "It's that person.

//This will always output "It's that person" because "The Fizz Meister" and "The Fizz" evaluate to true.

The above example is a no-no. The below example is how it should be done:
mob/proc/yea()
if(src.key == "Popisfizzy"||src.key == "The Fizz Meister"||src.key == "The Fizz") world << "Look, it's [src.name]"
else world << "It's that person."

//This, on the other hand, will output "Look, it's [src.name]" if it's one of my keys
In response to Popisfizzy
Thanks guys, I just trashed it and made a new one