From 0509e2669080cc9a6a90676a4503f7a18a7537b3 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 26 Sep 2015 20:45:19 +0200 Subject: [PATCH] Code Cleanup NoRadio --- addons/noradio/CfgEventhandlers.hpp | 10 +++++----- addons/noradio/XEH_postInit.sqf | 24 +++++++++++++++++++++++ addons/noradio/XEH_post_initClient.sqf | 27 -------------------------- addons/noradio/XEH_post_initServer.sqf | 6 ------ 4 files changed, 29 insertions(+), 38 deletions(-) create mode 100644 addons/noradio/XEH_postInit.sqf delete mode 100644 addons/noradio/XEH_post_initClient.sqf delete mode 100644 addons/noradio/XEH_post_initServer.sqf diff --git a/addons/noradio/CfgEventhandlers.hpp b/addons/noradio/CfgEventhandlers.hpp index d960e896df..386d98d241 100644 --- a/addons/noradio/CfgEventhandlers.hpp +++ b/addons/noradio/CfgEventhandlers.hpp @@ -1,6 +1,6 @@ + class Extended_PostInit_EventHandlers { - class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_post_initClient)); - serverInit = QUOTE(call COMPILE_FILE(XEH_post_initServer)); - }; -}; \ No newline at end of file + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/noradio/XEH_postInit.sqf b/addons/noradio/XEH_postInit.sqf new file mode 100644 index 0000000000..4aeccffd62 --- /dev/null +++ b/addons/noradio/XEH_postInit.sqf @@ -0,0 +1,24 @@ +// 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 {}; + +// mutes/unmutes units when the player changes +["playerChanged", { + 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 EFUNC(common,addEventhandler); diff --git a/addons/noradio/XEH_post_initClient.sqf b/addons/noradio/XEH_post_initClient.sqf deleted file mode 100644 index ecd80a6436..0000000000 --- a/addons/noradio/XEH_post_initClient.sqf +++ /dev/null @@ -1,27 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -/* -[{ - if (!isNull ACE_player) then { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - - [ACE_player, "isPlayer"] call EFUNC(common,muteUnit); - }; -}, 0, []] call CBA_fnc_addPerFrameHandler; -*/ - -if (!hasInterface) exitWith {}; - -// Mutes/unmutes units when the player changes -["playerChanged", { - EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer); - - // On player change 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 EFUNC(common,addEventhandler); diff --git a/addons/noradio/XEH_post_initServer.sqf b/addons/noradio/XEH_post_initServer.sqf deleted file mode 100644 index ae2dc16ec1..0000000000 --- a/addons/noradio/XEH_post_initServer.sqf +++ /dev/null @@ -1,6 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -addMissionEventHandler ["HandleDisconnect", { - [_this select 0, "isPlayer"] call EFUNC(common,unmuteUnit); -}];