View Single Post
  #1  
Old 09-12-2008, 11:23 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Unhappy stefans health sys guide help

i foloed this guide to the bottom
and when i use the sword one it hurts myself
ill show ya what i put

i put this in the hpsys
PHP Code:
if (actionserverattack) {
  
// A sword-type weapon
  // Check for players
  
this.attackx playerx 1.5 vecx(playerdir)*2;
  
this.attacky playery 2   vecy(playerdir)*2;
  
this.attackpower 1;
  
attackplayers();
  
attacknpcs();
}
function 
attackplayers() {
  
pid playerid;
  
pindexes getnearestplayers(this.attackx,this.attacky,playerid!=pid);
  
dist  0;
  for (
i=0i<arraylen(pindexes); i++) {
    
with (players[pindexes[i]]) {
      
dx playerx 1.5 this.attackx;
      
dy playery 2   this.attacky;
      
dist = (dx*dx dy*dy)^0.5;
      if (
dist<=2)
        
hurtplayer();
    }
    if (
dist>2)
      break;
  }
function 
hurtplayer() {
  
newhp strtofloat(#s(clientr.hp)) - this.attackpower;
  
if (newhp<=0) {
    
newhp 3;
    
setani dead,;
  } else {
    
setani hurt,;
  }
  
setstring clientr.hp,#v(newhp);
}


PHP Code:
put this in the sword
//#CLIENTSIDE
if (weaponfired) {
  
setani dg_katana_attack,;
  
freezeplayer 0.25;
  
triggeraction 0,0,serverattack,;

put this in npcserver
PHP Code:
if (actionserverattack) {
  
// A sword-type weapon
  // Check for players
  
this.attackx playerx 1.5 vecx(playerdir)*2;
  
this.attacky playery 2   vecy(playerdir)*2;
  
this.attackpower 1;
  
attackplayers();
  
attacknpcs();

join hpfunctions;} 
put this in the class called
hpfunctions
PHP Code:
function attackplayers() {
  
pid playerid;
  
pindexes getnearestplayers(this.attackx,this.attacky,playerid!=pid);
  
dist  0;
  for (
i=0i<arraylen(pindexes); i++) {
    
with (players[pindexes[i]]) {
      
dx playerx 1.5 this.attackx;
      
dy playery 2   this.attacky;
      
dist = (dx*dx dy*dy)^0.5;
      if (
dist<=2)
        
hurtplayer();
    }
    if (
dist>2)
      break;
  }
}
function 
hurtplayer() {
  
newhp strtofloat(#s(clientr.hp)) - this.attackpower;
  
if (newhp<=0) {
    
newhp 3;
    
setani dead,;
  } else {
    
setani hurt,;
  }
  
setstring clientr.hp,#v(newhp);

and note*i didint use the arrow 1 because the script had an error because when i hit apply it had an error so i only did sword*note
Reply With Quote