Quote:
Originally Posted by MrOmega
PHP Code:
for ( temp.p = 0; temp.p < allPlayerscount; temp.p ++;) {
//Use if to check player coords with players[ temp.p]
}
|
If you're using allplayerscount, then you need to use
allplayers, not
players.
You should also use
allplayers.size() rather than
allplayerscount as it makes no sense to use the latter.
I would recommend using a foreach loop.
PHP Code:
function hitPlayers(x, y, radius) {
for (temp.pl : findNearestPlayers(x, y)) {
if (getDistance(pl.x, pl.y, x, y) < radius && pl != player) {
pl.chat = "I was hit!";
}
}
}
function getDistance(x1, y1, x2, y2) {
return (((x1 - x2) ^ 0.5) + ((y1 - y2) ^ 0.5)) ^ 2;
}
This should work, haven't tested it though.