29.08.2014, 15:42
You can use stock GetClosestPlayer(playerid);
Код:
stock GetClosestPlayer(playerid) { new Float:dis,Float:dis2,player; player = -1; dis = 99999.99; foreach(Player,x) { if(x != playerid) { dis2 = GetDistanceBetweenPlayers(x,playerid); if(dis2 < dis && dis2 != -1.00) { dis = dis2; player = x; } } } return player; } CMD:rob(playerid, params[]) { if(GetClosestPlayer(playerid) == -1) return SendClientMessage(ID, 0xFF0000AA, "ERROR : No player close to you!"); printf("Player with ID %i is closest to you!", GetClosestPlayer(playerid)); return 1; }