Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add boxGuard ACE3 interaction menu for unlocking a box #42

Merged
merged 1 commit into from
Sep 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;