15.10.2013, 11:40
I use some sort of this in my server...
pawn Код:
stock GetClosestPlayer(playerid)
{
new Float:cdist, targetid = -1;
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && GetPlayerState(i) != PLAYER_STATE_SPECTATING && playerid != i && (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i)))
{
targetid = i;
cdist = GetDistanceBetweenPlayers(playerid, i);
}
}
return targetid;
}
//
new Tplayer = GetClosestPlayer(playerid);// use this in command
//