2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-23 22:40:39 +00:00
|
|
|
/*
|
2015-03-15 16:27:21 +00:00
|
|
|
* Author: PabstMirror
|
|
|
|
* Adds a key to a unit that will open a vehicle
|
|
|
|
* Note: has global effects for Unit (will add items to remote unit)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Vehicle <OBJECT>
|
|
|
|
* 2: custom key (true: custom key (magazine) - false: side key (item)) <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ACE_player, car, true] call ACE_VehicleLock_fnc_addKeyForVehicle
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-08-07 18:24:47 +00:00
|
|
|
if (!params [["_unit", objNull, [objNull]], ["_veh", objNull, [objNull]], ["_useCustom", false, [false]]]) exitWith {
|
|
|
|
ERROR("Input wrong type");
|
|
|
|
};
|
|
|
|
TRACE_3("params",_unit,_veh,_useCustom);
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
if (isNull _unit) exitWith {ERROR("null unit");};
|
|
|
|
if (isNull _veh) exitWith {ERROR("null vehicle");};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
|
|
|
if (_useCustom) then {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _previousMags = magazinesDetail _unit;
|
2015-03-15 16:27:21 +00:00
|
|
|
_unit addMagazine ["ACE_key_customKeyMagazine", 1]; //addMagazine array has global effects
|
2017-10-10 14:39:59 +00:00
|
|
|
private _newMags = (magazinesDetail _unit) - _previousMags;
|
2015-03-15 16:27:21 +00:00
|
|
|
if ((count _newMags) == 0) exitWith {ERROR("failed to add magazine (inventory full?)");};
|
2017-10-10 14:39:59 +00:00
|
|
|
private _keyMagazine = _newMags select 0;
|
2015-03-15 16:27:21 +00:00
|
|
|
TRACE_2("setting up key on server",_veh,_keyMagazine);
|
|
|
|
//Have the server run add the key to the vehicle's key array:
|
2016-05-25 00:37:24 +00:00
|
|
|
[QGVAR(setupCustomKey), [_veh, _keyMagazine]] call CBA_fnc_serverEvent;
|
2015-01-23 22:40:39 +00:00
|
|
|
} else {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _keyName = [_veh] call FUNC(getVehicleSideKey);
|
2015-03-15 16:27:21 +00:00
|
|
|
_unit addItem _keyName; //addItem has global effects
|
2015-01-23 22:40:39 +00:00
|
|
|
};
|