It's like:
PHP Code:
players = getentarray("player", "classname");
playerNearestDistance = 9999999999;
playerNearest = undefined;
for (i=0; i<players.size; i++)
{
if (self == players[i])
continue;
distanceToThis = distancesquared(players[i].origin, self.origin);
if (distanceToThis < playerNearestDistance)
{
playerNearestDistance = distanceToThis;
playerNearest = players[i];
}
}
if (isDefined(playerNearest))
iprintln("found the nearest player: ", playerNearest.origin, " id: ", playerNearest getEntityNumber());
else
iprintln("no near player");