View Single Post
  #3  
Old 02-11-2010, 01:53 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
It is usually best to do the entire thing serverside


PHP Code:
function attack(dx, dy) {
  for (
temp.pl : findNearestPlayers(dx, dy)) {
    if (! (
dx in |player.x, player.x + 3| && dy in |player.y, player.y + 3|)) {
      continue;
    }
    
    if (
pl == player) { // if it's the attacking player, skip
      
continue;
    }
    
    
pl.hit(0.5, player);
  }
} 
then in the player class,

PHP Code:
public function hit(damage, pl) {
  
this.hearts -= damage;
  
this.chat = "Hurt by: " @ pl.account;
  
this.setAni("human2_hurt", null);
} 

However, if you choose to do it clientside, you will need a weapon to intercept the trigger. Once you intercept it clientside in a weapon, you will need to trigger serverside again in that weapon then call the player function as player.hearts can't be modified clientside.
__________________
Reply With Quote