diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 696aa16f9b..7d81c908ad 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,12 +1,6 @@ // ACE - Common #include "script_component.hpp" -// Load settings from profile -if (hasInterface) then { - call FUNC(loadSettingsFromProfile); - call FUNC(loadSettingsLocalizedText); -}; - // Listens for global "SettingChanged" events, to update the force status locally ["SettingChanged", { @@ -249,3 +243,17 @@ if(isMultiplayer && { time > 0 || isNull player } ) then { }; }, 0, []] call cba_fnc_addPerFrameHandler; }; + +GVAR(commonPostInited) = true; + +// Create a pfh to wait until all postinits are ready and settings are initialized +[{ + // If post inits are not ready then wait + if !(SLX_XEH_MACHINE select 8) exitWith {}; + // If settings are not initialized then wait + if !(GVAR(SettingsInitialized)) exitWith {}; + + diag_log text format["[ACE] Settings initialized"]; + ["SettingsInitialized", []] call FUNC(localEvent); + +}, 0, []] call cba_fnc_addPerFrameHandler; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 7c8f36163a..2f74cad3a8 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -291,9 +291,22 @@ GVAR(syncedEvents) = HASH_CREATE; //Debug ACE_COUNTERS = []; -// Load settings +// Wait for server settings to arrive +GVAR(SettingsInitialized) = false; +["ServerSettingsReceived", { + // Load user settings from profile + if (hasInterface) then { + call FUNC(loadSettingsFromProfile); + call FUNC(loadSettingsLocalizedText); + }; + GVAR(SettingsInitialized) = true; +}] call FUNC(addEventhandler); + +// Load settings on the server and broadcast them if (isServer) then { call FUNC(loadSettingsOnServer); + // Raise a local event for other modules to listen too + ["SettingsInitialized", []] call FUNC(localEvent); }; ACE_player = player;