Quote:
Originally Posted by BrianD
I use findnearestplayers to recognize the closest player, and tokenize it, however this sometimes turns out in client.hurt[1] being my own account, and not the nearest account besides my own. in theory, client.hurt[0] should be my own account, and the second closest player to me besides myself is client.hurt[1]...however it's sporadic and i'm not sure why.
|
You do need to work on your styling, but anyway... Examine this.
PHP Code:
for (temp.pl: findnearestplayers(temp.x, temp.y)) {
// make sure the player cannot hit self
if (temp.pl == player)
continue;
// break the loop if the target is not in range
if (vectordist({temp.pl.x, temp.pl.y, 0}, {temp.x, temp.y, 0}) > 3)
break;
// damage target
temp.pl.damageTarget();
}