Skip to content

Commit

Permalink
Update fn_isPlayerNear.sqf
Browse files Browse the repository at this point in the history
  • Loading branch information
10Dozen authored Oct 1, 2016
1 parent 1cce5ae commit c5f2d32
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions dzn_commonFunctions/functions/areaFunctions/fn_isPlayerNear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@

params["_pos", ["_dist", 1000], ["_mode", "bool"]];

#define BOOL_MODE toLower(_mode) == "bool"
#define IS_NEAR (getPosASL _x) distance _pos <= _dist

_pos = if (typename (_this select 0) == "ARRAY") then { _this select 0 } else { getPosASL (_this select 0) };
private _r = if (BOOL_MODE) then { false } else { objNull };

private _r = if (toLower(_mode) == "bool") then { false } else { objNull };
{
if ((getPosASL _x) distance _pos <= _dist) exitWith {
_r = if (toLower(_mode) == "bool") then { true } else { _x };
};
} forEach (call BIS_fnc_listPlayers);
if (BOOL_MODE) then {
_r = { IS_NEAR } count (call BIS_fnc_listPlayers) > 0;
} else {
{
if ( IS_NEAR ) exitWith {
_r = _x;
};
} forEach (call BIS_fnc_listPlayers);
};

_r

0 comments on commit c5f2d32

Please sign in to comment.