There's a couple problems, but the main one is you're using it wrong. It's not returning a string of accounts, it's returning an array of players. The only reason tokenizing it works is because it's being coerced into a string of comma-separated accounts.
Try this instead:
PHP Code:
temp.closePlayers = findNearestPlayers(temp.x, temp.y);
temp.playerToHit = null;
for (temp.closePlayer : temp.closePlayers) {
if (temp.closePlayer == player) {
continue; // can't hit yourself
}
temp.playerToHit = temp.closePlayer;
}
Then you can use
temp.playerToHit which is a player object of the closest player.