ACE3/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf

46 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-01-23 22:40:39 +00:00
/*
Name: ACE_VehicleLock_fnc_hasKeyForVehicle
Author: Pabst Mirror
Description:
Returns if user has a valid key for the vehicle
Parameters:
0: OBJECT - unit
1: OBJECT - vehicle
Returns:
BOOL - unit has key for vehicle
Example:
[bob, car] call ACE_VehicleLock_fnc_hasKeyForVehicle;
*/
#include "script_component.hpp"
private ["_unit","_veh","_returnValue","_sideKeyName","_customKeys"];
_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param;
_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param;
if (isNull _unit) exitWith {["ACE_VehicleLock_fnc_hasKeyForVehicle: null unit"] call BIS_fnc_error; false};
if (isNull _veh) exitWith {["ACE_VehicleLock_fnc_hasKeyForVehicle: null vehicle"] call BIS_fnc_error; false};
_returnValue = false;
//Master can open anything "no matter what"
if ("ACE_key_master" in (items _unit)) then {_returnValue = true};
//Check side key
_sideKeyName = [_veh] call FUNC(getVehicleSideKey);
if (_sideKeyName in (items _unit)) then {_returnValue = true};
//Check custom keys
_customKeys = _veh getVariable [QGVAR(customKeys), []];
{
if (_x in (magazinesDetail _unit)) then {_returnValue = true;};
} forEach _customKeys;
_returnValue