ACE3/addons/map_gestures/functions/fnc_getProximityPlayers.sqf
Smith 5a6b21dd0b
Map Gestures - Fix briefing mode group (#8025)
* fix getting players from a group

* add brackets

Co-authored-by: jonpas <jonpas33@gmail.com>

* small refactoring

* remove useless parentheses

Co-authored-by: commy2 <commy-2@gmx.de>

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: commy2 <commy-2@gmx.de>
2020-12-02 08:49:35 -06:00

57 lines
1.6 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Dslyecxi, MikeMatrix
* Returns all players in a given range and in the units vehicle.
*
* Arguments:
* 0: Positions (objects or posAGLs) <ARRAY>
* 1: Range <NUMBER>
*
* Return Value:
* All units in proximity with Distances to render from <ARRAY<ARRAY<OBJECT,NUMBER>>>
*
* Example:
* [[[player, 6]]] call ace_map_gestures_fnc_getProximityPlayers
*
* Public: No
*/
private _proximityPlayers = [];
private _fnc_getProximitsPlayers = {
{
_x params ["_position", ["_range", GVAR(maxRange)]];
private _temp = (_position nearEntities [["CAMAnBase"], _range]);
if (_position isEqualType objNull) then {
_temp append (crew vehicle _position);
if (GVAR(onlyShowFriendlys)) then {
_temp = _temp select { [side group _position, side _x] call BIS_fnc_areFriendly; };
};
};
_proximityPlayers append _temp;
} forEach _this;
};
switch (_this) do {
case (0): { // All
_proximityPlayers append allUnits;
};
case (1): { // Players in Group
_proximityPlayers append units ace_player;
};
case (2): { // Players on Side
_proximityPlayers append (allUnits select {side (group _x) == side (group ace_player)});
};
case (3): { // Proximity
[[ace_player, GVAR(maxRange)]] call _fnc_getProximitsPlayers;
};
case (4): {}; // Disabled
default {
_this call _fnc_getProximitsPlayers;
};
};
_proximityPlayers = _proximityPlayers arrayIntersect _proximityPlayers;
_proximityPlayers = _proximityPlayers select { [_x, false] call EFUNC(common,isPlayer); };
_proximityPlayers