diff --git a/addons/hearing/XEH_postInit.sqf b/addons/hearing/XEH_postInit.sqf index e0bee153f8..93a86f7349 100644 --- a/addons/hearing/XEH_postInit.sqf +++ b/addons/hearing/XEH_postInit.sqf @@ -11,6 +11,23 @@ if (isServer) then { }] call CBA_fnc_addEventHandler; }; +["CBA_settingsInitialized", { + TRACE_1("settingInit - common",GVAR(enableCombatDeafness)); + // Only install event handler if combat deafness is enabled + if (!GVAR(enableCombatDeafness)) exitWith {}; + + addMissionEventHandler ["ProjectileCreated", { + params ["_projectile"]; + + if (!local _projectile) exitWith {}; + + // Rockets only explode on local clients + _projectile addEventHandler ["Explode", { + [QGVAR(explosion), _this] call CBA_fnc_globalEvent; + }]; + }]; +}] call CBA_fnc_addEventHandler; + if (!hasInterface) exitWith {}; #include "initKeybinds.inc.sqf" @@ -27,7 +44,7 @@ GVAR(volumeAttenuation) = 1; GVAR(lastPlayerVehicle) = objNull; ["CBA_settingsInitialized", { - TRACE_1("settingInit",GVAR(enableCombatDeafness)); + TRACE_1("settingInit - client",GVAR(enableCombatDeafness)); // Only run PFEH and install event handlers if combat deafness is enabled if (!GVAR(enableCombatDeafness)) exitWith {}; @@ -92,17 +109,6 @@ GVAR(lastPlayerVehicle) = objNull; call FUNC(updateHearingProtection); }, true] call CBA_fnc_addPlayerEventHandler; - addMissionEventHandler ["ProjectileCreated", { - params ["_projectile"]; - - if (!local _projectile) exitWith {}; - - // Rockets only explode on local clients - _projectile addEventHandler ["Explode", { - [QGVAR(explosion), _this] call CBA_fnc_globalEvent; - }]; - }]; - // Update protection on possible helmet change ["loadout", LINKFUNC(updateHearingProtection), false] call CBA_fnc_addPlayerEventHandler; }] call CBA_fnc_addEventHandler;