diff --git a/addons/noradio/XEH_post_initClient.sqf b/addons/noradio/XEH_post_initClient.sqf index fcdeeec7e3..e192a101f8 100644 --- a/addons/noradio/XEH_post_initClient.sqf +++ b/addons/noradio/XEH_post_initClient.sqf @@ -13,13 +13,19 @@ _setupPlayer = { [_setupPlayer, 0, []] call CBA_fnc_addPerFrameHandler; -[missionNamespace, "playerChanged", { - //On player change, mute old unit and unmute new player - [_this select 0] call EFUNC(common,muteUnit); - (_this select 0) setVariable [QGVAR(isMuted), true, true]; +// Mutes/unmutes units when the player changes +["playerChanged", { + EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer); - if (!((_this select 1) getVariable ["ACE_isUnconscious", false]) && {alive (_this select 1)}) then { //@todo: ACE_isUnconscious??? - [_this select 1] call EFUNC(common,unMuteUnit); + // On player change mute the new player + [_newPlayer] call EFUNC(common,muteUnit); + _newPlayer setVariable [QGVAR(isMuted), true, true]; + + // Unmute the old player + //@todo: sort interaction with medical system + if (!(_oldPlayer getVariable ["ACE_isUnconscious", false]) && {alive _oldPlayer}) then { + [_oldPlayer] call EFUNC(common,unMuteUnit); }; - (_this select 1) setVariable [QGVAR(isMuted), false, true]; -}] call EFUNC(common,addCustomEventHandler); + _oldPlayer setVariable [QGVAR(isMuted), false, true]; + +}] call EFUNC(common,addEventhandler);