GetClosestPlayer Bug
#3

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

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;
}
Reply


Messages In This Thread
GetClosestPlayer Bug - by Stefand - 26.08.2014, 17:54
Re: GetClosestPlayer Bug - by Aerotactics - 26.08.2014, 19:16
Re: GetClosestPlayer Bug - by Pottus - 26.08.2014, 19:26
Re: GetClosestPlayer Bug - by Stefand - 26.08.2014, 21:09
Re: GetClosestPlayer Bug - by Pottus - 26.08.2014, 21:47
Re: GetClosestPlayer Bug - by Stefand - 27.08.2014, 06:01
Re: GetClosestPlayer Bug - by MicroD - 27.08.2014, 07:18

Forum Jump:


Users browsing this thread: 1 Guest(s)