DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_IsPlayerNearby.sqf
2016-06-06 22:47:15 -05:00

56 lines
922 B
Plaintext

/*
DMS_fnc_IsPlayerNearby
Created by eraser1
Usage:
[
_positionOrObject,
_distance
] call DMS_fnc_IsPlayerNearby;
Returns whether or not a player is within "_distance" meters of "_positionOrObject".
*/
if !(params
[
"_pos",
"_dis"
])
exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_IsPlayerNearby with invalid parameters: %1",_this];
false;
};
if (_dis isEqualTo 0) exitWith {false};
private _isNear = false;
try
{
{
{
if (isPlayer _x) then
{
throw _x;
};
} forEach (crew _x);
} forEach (_pos nearEntities [["Exile_Unit_Player","LandVehicle", "Air", "Ship"], _dis]);
if (DMS_DEBUG) then
{
(format ["IsPlayerNearby :: No players within %1 meters of %2!",_dis,_pos]) call DMS_fnc_DebugLog;
};
}
catch
{
_isNear = true;
if (DMS_DEBUG) then
{
(format ["IsPlayerNearby :: %1 is within %2 meters of %3!",_exception,_dis,_pos]) call DMS_fnc_DebugLog;
};
};
_isNear;