24.12.2010, 14:12
heres a better i think, shouldnt range be 99999 for the whole of san andreas?
pawn Код:
public GetClosestPlayer(p1)
{
new Float:dis,Float:dis2,player;
player = -1;
dis = 99999.99;
foreach(Player,x)
{
if(x != p1)
{
dis2 = GetDistanceBetweenPlayers(x,p1);
if(dis2 < dis && dis2 != -1.00)
{
dis = dis2;
player = x;
}
}
}
return player;
}
new closest = GetClosestPlayer(playerid);
if(closest == -1 || GetDistanceBetweenPlayers(playerid,closest) > 7) return SendClientMessage(playerid,COLOR_RED,"There are no players closes enough");