26.08.2014, 21:47
Quote:
@Pottus, would there be a way to make that only work within a range of 10.0?
|
It's pretty easy to make a function to do that though.
pawn Код:
#if !defined INFINITY
#define INFINITY (Float:0x7F800000)
#endif
GetClosestPlayerInRange(playerid, Float:range)
{
new Float:x, Float:y, Float:z, Float:dist, Float:closedist = INFINITY, closeid = INVALID_PLAYER_ID;
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i) ||
IsPlayerNPC(i) ||
i == playerid)
continue;
else
{
dist = GetPlayerDistanceFromPoint(i, x, y, z);
if(dist <= range)
{
if(dist < closedist)
{
closedist = dist;
closeid = i;
}
}
}
}
return closeid;
}