ID:143685
 
Code:
area
NonPK_Zone
Entered(atom/O)
..()
if(ismob(O))
usr.PK=0
return ..()
Exited(atom/O)
..()
if(ismob(O))
usr.PK=1
return ..()


mob/var/PK = 1


Problem description:
If the PK = 0 you arent supposed to use jtusus or attack (naruto game).
When I load with my character on a place that has the NonPK Zone i still can attack and use jutsus. Even when I walk around in the NonPK Zone (and im sure i placed the NOn PK zone) it still allows me to use jutsus.
Now, when I walk out the Non PK zone andi wlak back in it i cant use jutsus because i set this to every jutsu/attack:
if(!usr.PK)return

My apologies if I made a dumb mistake, but this is the first time I made such a system.

Regards,

Rick(Sokkiejjj) ~NUR Owner

Never use usr in Enter or Entered, this is an example of how you should code your enter
area/NoNPK_Zone
Entered(atom/movable/A)
var/mob/M = A
if(istype(A, /mob/))
M.PK = 0
M << "You entered a non Player Killing Zone!"

In response to Miran94
And how'd you code the exit?
In response to Sokkiejjj
Same Way.
In response to Miran94
Thank you.
I really didn't know, lol.
In response to Sokkiejjj
Your Welcome and did it work for you?
In response to Miran94
Just use:

area/var/noPK = 0 // set to 1 for safe zones

mob/verb/attack(mob/M)
var/area/A1 = src.loc.loc
var/area/A2 = M.loc.loc
if(A1.noPK || A2.noPK)
return
else
// do attack here


That'll check to see if the attacker's /area is noPK set, or if the victim's /area has noPK set. If either of them are set, then the attack won't happen (just in case someone standing inside the border attacks someone standing outside, or the other way around).

You can remove the second /area check if there's no particular victim for the attack.

If you do it this way, you never have to worry about a mob's PK variable getting set improperly somehow, thus allowing them to attack stuff or be attacked when they shouldn't be able to. (For example, if there was a direct src.loc = newloc on a mob, it wouldn't register with /area/Exited or /area/Entered, so the PK value wouldn't change.)
In response to Miran94
Well I still have the same problem.
When I load my character and walk around in the academy where i palced the area code i still can use jutsus.