View Single Post
  #4  
Old 02-11-2010, 02:17 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
It is usually best to do the entire thing serverside


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

then in the player class,

PHP Code:
public function hit(damagepl) {
  
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.
I think this is intended to be a Clientside Hit Detection, using the triggeraction method would only result in the function occuring if your player is positioned on the given coordinate at the time of the trigger being recieved on your own client.

I think the hearts variable can -falsely- be modified Clientside albeit for the illusion of no delay, which should be done along side the setting of the Gani, but yes hearts should definately be modified serverside either way.
(Edit: having tested it seemed hearts had saved having set a new value Clientside and reconnected)
Reply With Quote