Skip to content

Commit

Permalink
restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
OverlordZorn committed Sep 3, 2024
1 parent 50defd5 commit d3ebd38
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions addons/arsenal/functions/fn_eventHandlers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@ if !(hasInterface) exitWith {};
*
*/

["CBA_settingsInitialized", {

private _isEnabled = missionNamespace getVariable ["CVO_SET_Arsenal_saveOnArsenalClose", true];
if !(_isEnabled) exitWith {};

["ace_arsenal_displayClosed", {
player setVariable ["CVO_Loadout", getUnitLoadout player];
}] call CBA_fnc_addEventHandler;

},[]] call CBA_fnc_addEventHandler;


["CBA_settingsInitialized", {

private _isEnabled = missionNamespace getVariable ["CVO_SET_loadPlayerLoadoutOnRespawn", true];
if !(_isEnabled) exitWith {};

// when respawning, using the previously saved loadout
player addEventHandler ["Respawn", {
params ["_unit", "_corpse"];
player setUnitLoadout (player getVariable ["CVO_Loadout", []]);
}];
},[]] call CBA_fnc_addEventHandler;
private _code = {
["ace_arsenal_displayClosed", {
private _isEnabled = missionNamespace getVariable ["CVO_SET_Arsenal_saveOnArsenalClose", true];
if (_isEnabled) then {
[ { player setVariable ["CVO_Loadout", getUnitLoadout player]; } , [], 3] call CBA_fnc_waitAndExecute;
};
}] call CBA_fnc_addEventHandler;


player addEventHandler ["Respawn", {
private _isEnabled = missionNamespace getVariable ["CVO_SET_loadPlayerLoadoutOnRespawn", true];
if (_isEnabled) then {
params ["_unit", "_corpse"];
player setUnitLoadout (player getVariable ["CVO_Loadout", []]);
};
}];
};

if (missionNamespace getVariable ["cba_settings_ready",false]) then _code else { ["CBA_settingsInitialized",_code,[]] call CBA_fnc_addEventHandler; };

0 comments on commit d3ebd38

Please sign in to comment.