Getting lowest number and storing it in a variable
#7

Can't be bothered sorry, but here's my code for getting the closest player, it may be of some use:

pawn Code:
new Float:dist = FLOAT_INFINITY, closest_player = playerid;
        new Float:pos[3], Float:this_dist;
        foreach(new i : Player)
        {
            if(i == playerid) continue;
            GetPlayerPos(i, pos[0], pos[1], pos[2]);
            this_dist = GetPlayerDistanceFromPoint(playerid, pos[0], pos[1], pos[2]);
            if(this_dist < dist)
            {
                closest_player = i;
                dist = this_dist;
            }
        }
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)