diff --git a/cScripts/functions/init/fn_init_eventHandlers.sqf b/cScripts/functions/init/fn_init_eventHandlers.sqf index 51dafb69a..5cb28be98 100644 --- a/cScripts/functions/init/fn_init_eventHandlers.sqf +++ b/cScripts/functions/init/fn_init_eventHandlers.sqf @@ -40,6 +40,30 @@ if (GVAR(isPlayer)) then { //["zen_common_createZeus", { // _this params ["_zeus"]; //}] call CBA_fnc_addEventHandler; + + + // CavArsenal + ["ace_arsenal_displayClosed", { + if (GVAR(StagingArsenalOpen)) then { + [QEGVAR(EH_StagingArsenal,displayClose)] call CBA_fnc_localEvent; + }; + }] call CBA_fnc_addEventHandler; + + [QEGVAR(EH_StagingArsenal,displayOpen), { + GVAR(StagingArsenalOpen) = true; + }] call CBA_fnc_addEventHandler; + + [QEGVAR(EH_StagingArsenal,displayClosed), { + [player, true] call ace_arsenal_fnc_removeBox; + GVAR(StagingArsenalOpen) = false; + + // Reset default loadouts + call EFUNC(init,aceArsenalDefault); + + }] call CBA_fnc_addEventHandler; + + + }; diff --git a/cScripts/functions/systems/fn_addArsenal.sqf b/cScripts/functions/systems/fn_addArsenal.sqf index 9bf824134..25f19225d 100644 --- a/cScripts/functions/systems/fn_addArsenal.sqf +++ b/cScripts/functions/systems/fn_addArsenal.sqf @@ -20,10 +20,9 @@ private _arsenalStatement = { INFO_2("Staging Arsenal", "Creating staging arsenal for %1 (%2)", player, typeOf player); ace_arsenal_defaultLoadoutsList = []; - [] call FUNC(getUnitArsenalDefault); + call FUNC(getUnitArsenalDefault); private _items = call FUNC(getArsenalWhitelist); - [player, _items] call ace_arsenal_fnc_initBox; if (count _items == 0) exitWith { [ [], @@ -32,9 +31,13 @@ private _arsenalStatement = { [""] ] call CBA_fnc_notify; }; + + [player, _items] call ace_arsenal_fnc_initBox; + [{ INFO_2("Staging Arsenal", "Opening Staging Arsenal for %1 (%2)", player, typeOf player); [player, player, false] call ace_arsenal_fnc_openBox; + [QEGVAR(EH_StagingArsenal,displayOpen)] call CBA_fnc_localEvent; [{ private _loadout = [player] call EFUNC(gear,getCurrentLoadout); private _name = getText (missionConfigFile >> "CfgLoadouts" >> _loadout >> "displayName"); @@ -46,13 +49,4 @@ private _arsenalStatement = { INFO_2("Staging Arsenal", "Adding staging arsenal action to %1 (%2)", player, typeOf player); private _arsenalAction = [QEGVAR(Actions,ArsenalAction), "Arsenal", _icon, _arsenalStatement, {true}] call ace_interact_menu_fnc_createAction; -[player, 1, _category, _arsenalAction] call ace_interact_menu_fnc_addActionToObject; - -// Recreate after closing -["ace_arsenal_displayClosed", { - INFO_2("Arsenal", "Destroying %1 (%2) personal arsenal box.", player, typeOf player); - [player, true] call ace_arsenal_fnc_removeBox; - - // Resetting loadouts - call EFUNC(init,aceArsenalDefault); -}] call CBA_fnc_addEventHandler; +[player, 1, _category, _arsenalAction] call ace_interact_menu_fnc_addActionToObject; \ No newline at end of file