26.08.2014, 19:26
That would return the last closest player in the specified range lol.
Here is my method it does a little bit more instead of only getting the closest player it will get the distance to all players then sort the list.
https://sampforum.blast.hk/showthread.php?tid=343172 - Deep sort include
Here is my method it does a little bit more instead of only getting the closest player it will get the distance to all players then sort the list.
https://sampforum.blast.hk/showthread.php?tid=343172 - Deep sort include
pawn Код:
enum DISTINFO { Float:cdistance, distpid, }
new pdistance[MAX_PLAYERS][DISTINFO];
GetClosestPlayers(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i) || i == playerid)
{
pdistance[i][cdistance] = -1.0;
pdistance[i][distpid] = i;
}
else
{
pdistance[i][cdistance] = GetPlayerDistanceFromPoint(i, x, y, z);
pdistance[i][distpid] = i;
}
}
SortDeepArray(pdistance, cdistance);
return 1;
}