diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 9fbe84362a..24a9e4ab6e 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -152,10 +152,10 @@ call FUNC(checkFiles); //Set init finished and run all delayed functions: GVAR(settingsInitFinished) = true; - diag_log text format ["%1 delayed functions", (count GVAR(runAtSettingsInitialized))]; + diag_log text format ["[ACE] %1 delayed functions running", (count GVAR(runAtSettingsInitialized))]; { - _x params ["_args", "_code"]; - _args call _code; + _x params ["_func", "_params"]; + _params call _func; } forEach GVAR(runAtSettingsInitialized); }, 0, [false]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 12fdc5629d..56e3062cd2 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -157,6 +157,7 @@ PREP(requestCallback); PREP(resetAllDefaults); PREP(restoreVariablesJIP); PREP(revertKeyCodeLocalized); +PREP(runAfterSettingsInit); PREP(sanitizeString); PREP(sendRequest); PREP(serverLog); diff --git a/addons/common/functions/fnc_runAfterSettingsInit.sqf b/addons/common/functions/fnc_runAfterSettingsInit.sqf new file mode 100644 index 0000000000..cf3faa1d7e --- /dev/null +++ b/addons/common/functions/fnc_runAfterSettingsInit.sqf @@ -0,0 +1,27 @@ +/* + * Author: PabstMirror + * Executes code after setting are initilized. + * + * Argument: + * 0: Code to execute + * 1: Parameters to run the code with + * + * Return value: + * None + * + * Example: + * [{if (GVAR(setting) then {x} else {y};}, []] call ace_common_fnc_runAfterSettingsInit + * + * Public: No + */ +#include "script_component.hpp" + +params ["_func", "_params"]; + +if (GVAR(settingsInitFinished)) then { + //Setting Already Finished, Direct Run the code + _params call _func; +} else { + //Waiting on settings, throw it on the delayed run array + GVAR(runAtSettingsInitialized) pushBack [_func, _params]; +};