GetClosestPlayer Bug
#5

Quote:
Originally Posted by Stefand
Посмотреть сообщение
@Pottus, would there be a way to make that only work within a range of 10.0?
Well you could just check the list the afterwards basically it just gets every players position then sorts the list it was really meant as just another idea you might be interested in.

It's pretty easy to make a function to do that though.

pawn Код:
#if !defined INFINITY
    #define INFINITY (Float:0x7F800000)
#endif

GetClosestPlayerInRange(playerid, Float:range)
{
    new Float:x, Float:y, Float:z, Float:dist, Float:closedist = INFINITY, closeid = INVALID_PLAYER_ID;
    GetPlayerPos(playerid, x, y, z);

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i) ||
            IsPlayerNPC(i) ||
            i == playerid)
            continue;
        else
        {
            dist = GetPlayerDistanceFromPoint(i, x, y, z);
            if(dist <= range)
            {
                if(dist < closedist)
                {
                    closedist = dist;
                    closeid = i;
                }
            }
        }
    }
    return closeid;
}
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)