30.07.2010, 08:50
Hi Kar. You could try a different way of approaching it. Take a look at this function I quickly made up..
maxdis = The maximum possible distance between the players. If the function returns -1 there is noone within range. Give it a try.
Cheers,
TJ
Код:
public GetClosestPlayer(playerid,Float:maxdis) { new minid = -1; new Float:mindis; new Float:X, Float:Y, Float:Z; for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && !IsPlayerNPC(i)) { GetPlayerPos(i,X,Y,Z); if(IsPlayerInRangeOfPoint(playerid,maxdis,X,Y,Z)) { if(minid == -1) { minid = i; mindis = GetDistanceBetweenPlayers(playerid,i); } else if(GetDistanceBetweenPlayers(playerid,i) < mindis) { minid = i; mindis = GetDistanceBetweenPlayers(playerid,i); } } } } return minid; }
Cheers,
TJ