diff --git a/addons/headless/XEH_postInit.sqf b/addons/headless/XEH_postInit.sqf index b91bb537b5..7b8a4615dc 100644 --- a/addons/headless/XEH_postInit.sqf +++ b/addons/headless/XEH_postInit.sqf @@ -4,13 +4,13 @@ if (hasInterface && !isServer) exitWith {}; ["SettingsInitialized", { - // Exit if HC transferring disabled - if (!GVAR(Enabled)) exitWith {}; - if (isServer) then { - addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}]; + // Add disconnect EH if HC transferring enabled + if (GVAR(Enabled)) then { + addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}]; + }; } else { - // Register HC on server (this part happens on HC only) - ["ACE_HeadlessClientJoined", [player]] call EFUNC(common,serverEvent); + // Register HC (this part happens on HC only) + ["ACE_HeadlessClientJoined", [player]] call EFUNC(common,globalEvent); }; }] call EFUNC(common,addEventHandler); diff --git a/addons/headless/functions/fnc_handleConnectHC.sqf b/addons/headless/functions/fnc_handleConnectHC.sqf index f0273b8fda..19293e9229 100644 --- a/addons/headless/functions/fnc_handleConnectHC.sqf +++ b/addons/headless/functions/fnc_handleConnectHC.sqf @@ -17,8 +17,13 @@ params ["_headlessClient"]; -// Exit if already registered -if (_headlessClient in GVAR(headlessClients)) exitWith {}; +// Delay until settings are initialized (for checking if HC trasnferring is enabled) +if (!EGVAR(common,settingsInitFinished)) exitWith { + EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(handleConnectHC), _this]; +}; + +// Exit if HC transferring disabled or HC already registered +if (!GVAR(Enabled) || {_headlessClient in GVAR(headlessClients)}) exitWith {}; // Register for use GVAR(headlessClients) pushBack _headlessClient;