07.07.2014, 02:30
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;
}