ACE3/addons/switchunits/functions/fnc_nearestPlayers.sqf

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