Skip to content

Commit

Permalink
add boxGuard ACE3 interaction menu for unlocking a box
Browse files Browse the repository at this point in the history
Signed-off-by: freghar <[email protected]>
  • Loading branch information
freghar authored and JamesTheClarke committed Sep 11, 2022
1 parent 83c1ddd commit 551cb64
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions addons/functions/loadout/fn_boxGuard.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@
params ["_box", "_range"];

if (isServer) then {
_box setVariable ["boxguard_data", [
_box setVariable ["cnto_boxguard_data", [
position _box, _range
], true];
};
if (hasInterface) then {
_box addEventHandler ["ContainerOpened", {
params ["_box", "_player"];

private _data = _box getVariable "boxguard_data";
private _disabled = _box getVariable ["cnto_boxguard_disabled", false];
if (_disabled) exitWith {
_box removeEventHandler ["ContainerOpened", _thisEventHandler];
};

private _data = _box getVariable "cnto_boxguard_data";
if (isNil "_data") exitWith {};
_data params ["_initpos", "_range"];
if (position _box distance2D _initpos > _range) exitWith {};
if (position _box distance2D _initpos > _range) exitWith {
_box setVariable ["cnto_boxguard_disabled", true, true];
};

0 = [] spawn {
waitUntil { !isNull findDisplay 602 };
Expand All @@ -26,3 +33,18 @@ if (hasInterface) then {
};
}];
};

private _action = [
"cnto_boxguard_action_disable",
"Unlock supply box",
"",
{ _target setVariable ["cnto_boxguard_disabled", true, true] },
{ rankId _player >= 3 && !(_target getVariable ["cnto_boxguard_disabled", false]) }
] call ace_interact_menu_fnc_createAction;

[
_box,
0,
["ACE_MainActions"],
_action
] call ace_interact_menu_fnc_addActionToObject;

0 comments on commit 551cb64

Please sign in to comment.