GetClosestPlayer (originally posted by cessil)
#6

pawn Код:
stock GetClosestPlayer(playerid, Float:dis)
{
    new x, Float:dis2, player;
    player = -1;
    for (x = 0; x < MAX_PLAYERS; x++)
    {
        if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_SPECTATING)
        {
            if(x != playerid)
            {
                dis2 = GetDistanceBetweenPlayers(x,playerid);
                if(dis2 < dis && dis2 != -1.00)
                {
                    dis = dis2;
                    player = x;
                }
            }
        }
    }
    return player;
}
Try this, I tweaked it a little bit to try to suit the one you posted.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)