ACE3/addons/switchunits/functions/fnc_nearestPlayers.sqf
2016-01-10 19:08:28 +01:00

30 lines
604 B
Plaintext

/*
* Author: bux578
* Returns an array of alive players in a given radius around a given location
*
* Arguments:
* 0: Center position <POSTION>
* 1: Radius <NUMBER>
*
* Return Value:
* Player units <ARRAY<OBJECT>>
*
* Example:
* [[300,300,0], 100] call ace_switchunits_fnc_nearestPlayers
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_position", "_radius"];
private _nearestPlayers = [];
{
if ([_x] call EFUNC(common,isPlayer) && {alive _x}) then {
_nearestPlayers pushBack _x;
};
} forEach (nearestObjects [_position, ["Man"], _radius]);
_nearestPlayers