Quote:
Originally Posted by 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.
|
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)