28.02.2009, 16:34
pawn Код:
stock GetClosestPlayer(playerid) //By Slick (edited by Gabriel "Larcius" Cordes)
{
if(IsPlayerConnected(playerid) && IsPlayerConnected(0))
{
new closestplayer=0;
new Float:closestdist=GetDistanceBetweenPlayers(playerid,0);
for(new playerid2=0; playerid2<MAX_PLAYERS; playerid2++)
{
new Float:dist = GetDistanceBetweenPlayers(playerid,playerid2);
if ((dist < closestdist))
{
closestdist = dist;
closestplayer = playerid;
}
}
return closestplayer;
}
return -1;
}