From 187e2b2d04b36de31d211cc1862bb5fdc3001603 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 12 Nov 2017 11:34:10 -0600 Subject: [PATCH] Add CBA setting for noRadio (#5571) * Add ace_setting for noRadio * Delay adding server EH * make noradio a cba setting --- addons/noradio/CfgEventhandlers.hpp | 4 +-- addons/noradio/XEH_postInit.sqf | 29 ---------------------- addons/noradio/XEH_preInit.sqf | 38 +++++++++++++++++++++++++++++ addons/noradio/stringtable.xml | 13 ++++++++++ 4 files changed, 53 insertions(+), 31 deletions(-) delete mode 100644 addons/noradio/XEH_postInit.sqf create mode 100644 addons/noradio/XEH_preInit.sqf create mode 100644 addons/noradio/stringtable.xml diff --git a/addons/noradio/CfgEventhandlers.hpp b/addons/noradio/CfgEventhandlers.hpp index b0cc92b5137..b928bc2de6e 100644 --- a/addons/noradio/CfgEventhandlers.hpp +++ b/addons/noradio/CfgEventhandlers.hpp @@ -1,5 +1,5 @@ -class Extended_PostInit_EventHandlers { +class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; diff --git a/addons/noradio/XEH_postInit.sqf b/addons/noradio/XEH_postInit.sqf deleted file mode 100644 index 6ca39e0c232..00000000000 --- a/addons/noradio/XEH_postInit.sqf +++ /dev/null @@ -1,29 +0,0 @@ -// By commy2 -#include "script_component.hpp" - -// Unmute unit if that player disconnects -if (isServer) then { - addMissionEventHandler ["HandleDisconnect", { - [_this select 0, "isPlayer"] call EFUNC(common,unmuteUnit); - }]; -}; - -if (!hasInterface) exitWith {}; - -// Handle early CBA_fnc_addPlayerEventHandler -if (!isNull ace_player) then { - [ace_player, "isPlayer"] call EFUNC(common,muteUnit); -}; - -// Mutes/unmutes units when the player changes -["unit", { - params ["_newPlayer", "_oldPlayer"]; - - // Mute the new player - [_newPlayer, "isPlayer"] call EFUNC(common,muteUnit); - - // Unmute the old player - if (alive _oldPlayer) then { - [_oldPlayer, "isPlayer"] call EFUNC(common,unmuteUnit); - }; -}] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/noradio/XEH_preInit.sqf b/addons/noradio/XEH_preInit.sqf new file mode 100644 index 00000000000..7cea9dedbd7 --- /dev/null +++ b/addons/noradio/XEH_preInit.sqf @@ -0,0 +1,38 @@ +// By commy2 +#include "script_component.hpp" + +if (isServer) then { + // Unmute unit if that player disconnects + addMissionEventHandler ["HandleDisconnect", { + TRACE_1("re-enabling voice",_this); + [_this select 0, "isPlayer"] call EFUNC(common,unmuteUnit); + }]; +}; + +if (hasInterface) then { + // Mutes/unmutes units when the player changes + ["unit", { + if (!GVAR(enabled)) exitWith {}; + + params ["_newPlayer", "_oldPlayer"]; + TRACE_2("player change",_newPlayer,_oldPlayer); + + // Mute the new player + [_newPlayer, "isPlayer"] call EFUNC(common,muteUnit); + + // Unmute the old player + if (alive _oldPlayer) then { + [_oldPlayer, "isPlayer"] call EFUNC(common,unmuteUnit); + }; + }, true] call CBA_fnc_addPlayerEventHandler; +}; + +[QGVAR(enabled), "CHECKBOX", [LSTRING(setting), LSTRING(setting_tooltip)], localize ELSTRING(common,ACEKeybindCategoryCommon), true, nil, { + params ["_enabled"]; + + if (_enabled) then { + [ACE_player, "isPlayer"] call EFUNC(common,muteUnit); + } else { + [ACE_player, "isPlayer"] call EFUNC(common,unmuteUnit); + }; +}] call CBA_settings_fnc_init; diff --git a/addons/noradio/stringtable.xml b/addons/noradio/stringtable.xml new file mode 100644 index 00000000000..4884c9760f0 --- /dev/null +++ b/addons/noradio/stringtable.xml @@ -0,0 +1,13 @@ + + + + + Mute Player + Spieler stummschalten + + + Mutes the controlled player avatar. + Schaltet eigenen Spieleravatar stumm. + + +