ACE3/addons/switchunits/functions/fnc_nearestPlayers.sqf

35 lines
663 B
Plaintext
Raw Normal View History

/*
2015-02-02 22:28:27 +00:00
* 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:
2015-04-17 20:45:00 +00:00
* [[300,300,0], 100] call FUNC(nearestPlayers)
2015-02-02 22:28:27 +00:00
*
* Public: Yes
*/
2015-01-12 14:47:22 +00:00
#include "script_component.hpp"
2015-04-17 20:45:00 +00:00
private ["_nearestPlayers"];
PARAMS_2(_position,_radius);
_position = _this select 0;
_radius = _this select 1;
_nearestPlayers = [];
{
2015-04-17 20:45:00 +00:00
if ([_x] call EFUNC(common,isPlayer) && {alive _x}) then {
_nearestPlayers pushBack _x;
};
} forEach (nearestObjects [_position, ["Man"], _radius]);
2015-04-17 20:45:00 +00:00
_nearestPlayers