29.08.2014, 22:57
pawn Код:
new Float:dist = 1000.0;
pawn Код:
stock GetNearestPlayer(playerid)
{
new Float:arr1[3], Float:arr2[3];
GetPlayerPos(playerid, arr1[0], arr1[1], arr1[2]);
for(new i; i <MAX_PLAYERS; i++)
{
if(i == playerid) continue;
GetPlayerPos(i, arr2[0], arr2[1], arr2[2]);
if(2.0 /* DISTANCE */ < floatsqroot(floatpower(floatabs(floatsub(arr1[0], arr2[0])),2)+floatpower(floatabs(floatsub(arr1[1], arr2[1])),2)+floatpower(floatabs(floatsub(arr1[2], arr2[2])),2))){
return i;
}
}
return -1;
}