I've already explained in other threads that you need to place the damage into another weapon, and even given you the code for the HP system:
Quote:
Originally Posted by cbk1994
PHP Code:
function onActionServerSide(cmd, damage) { if (cmd == "hit") { this.hitPlayer(damage); } }
function hitPlayer(damage) { player.clientr.hp = max (0, player.clientr.hp - damage); // max() chooses the largest of the two values if (player.clientr.hp <= 0) { this.playerDead(); } else { player.setAni("hurt", NULL); } }
function playerDead() { player.setAni("dead", NULL); player.setlevel2("onlinestartlocal.nw", 21, 55); // now you'll need eventually to heal them } //#CLIENTSIDE function onActionProjectile(damage) { triggerServer("gui", this.name, "hit", damage); }
|
Every player has to have the system weapon. The way it works is when a player is hit with a bullet, it calls the "onActionProjectile" event in every weapon. If a weapon has the event "defined", then it will be executed. If they don't have your gun script, which is where you mistakenly put the HP checks, then it won't be called.
Take your onActionProjectile code, place it in to a weapon like "-Health", and add a line of code in the Control-NPC to add it to players on login.
EDIT: Jerret beat me to it
