From ce23ed88adc71af3c0f48fdefb52261177bfb0da Mon Sep 17 00:00:00 2001 From: Sotirios Pupakis Date: Wed, 15 May 2024 13:46:16 +0200 Subject: [PATCH] Spectator mute (#1567) * Add settings, strings and auto send to plugin * spectator mute - plugin part --- addons/core/functions/fnc_initCBASettings.sqf | 10 +++++++++- addons/core/functions/plugin/fnc_sendPluginConfig.sqf | 1 + addons/core/stringtable.xml | 8 ++++++++ ts/src/plugin.cpp | 7 +++++++ ts/src/settings.hpp | 3 ++- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/addons/core/functions/fnc_initCBASettings.sqf b/addons/core/functions/fnc_initCBASettings.sqf index 2c7805067c..54b4148bfd 100644 --- a/addons/core/functions/fnc_initCBASettings.sqf +++ b/addons/core/functions/fnc_initCBASettings.sqf @@ -184,7 +184,15 @@ 0 ] call CBA_Settings_fnc_init; - +[ + "TFAR_muteSpectators", + "CHECKBOX", + [ELSTRING(settings,muteSpectators), ELSTRING(settings,muteSpectators_desc)], + localize ELSTRING(settings,clientside), + false, + 0, + {["muteSpectators", _this] call TFAR_fnc_setPluginSetting;} +] call CBA_Settings_fnc_init; diff --git a/addons/core/functions/plugin/fnc_sendPluginConfig.sqf b/addons/core/functions/plugin/fnc_sendPluginConfig.sqf index d1a96669d0..12679b9e3f 100644 --- a/addons/core/functions/plugin/fnc_sendPluginConfig.sqf +++ b/addons/core/functions/plugin/fnc_sendPluginConfig.sqf @@ -43,5 +43,6 @@ if !(missionNamespace getVariable ["TFAR_spectatorCanHearFriendlies",true]) then ["disableAutomaticMute", missionNamespace getVariable ["TFAR_disableAutoMute", false]] call TFAR_fnc_setPluginSetting; ["noAutomoveSpectator", missionNamespace getVariable ["TFAR_noAutomoveSpectator", true]] call TFAR_fnc_setPluginSetting; ["allowDebugging", missionNamespace getVariable ["TFAR_allowDebugging", false]] call TFAR_fnc_setPluginSetting; +["muteSpectators", missionNamespace getVariable ["TFAR_muteSpectators", false]] call TFAR_fnc_setPluginSetting; //If you add things that player could change in Mission call this PFH or tell players in WIKI diff --git a/addons/core/stringtable.xml b/addons/core/stringtable.xml index 90a29257fd..a77face80d 100644 --- a/addons/core/stringtable.xml +++ b/addons/core/stringtable.xml @@ -818,6 +818,14 @@ Nevynucovat přesun do kanálu TFAR v režimu diváka Не перемещать принудительно в канал TFAR в режиме наблюдателя + + Mute other spectators + Ztišit ostatní diváky + + + When spectating, mute other spectators and listen to alive players only + Při sledování ztišit ostatní diváky zatímco lze poslouchat hráče kteří jsou stále živí + Hide "Not connected" message Verstecke "Not connected" message diff --git a/ts/src/plugin.cpp b/ts/src/plugin.cpp index eaa1f3a75d..e2adc3a9d9 100644 --- a/ts/src/plugin.cpp +++ b/ts/src/plugin.cpp @@ -501,6 +501,13 @@ void processVoiceData(TSServerID serverConnectionHandlerID, TSClientID clientID, //If we are dead we can't hear anyone in seriousMode. And if we are alive we can't hear the dead. const bool isSpectator = clientData->isSpectating; + + // If I am dead and the speaker spectating, ignore if other spectators should be muted + if ((TFAR::config.get(Setting::muteSpectators)) && clientDataDir->myClientData->isSpectating && isSpectator) { + sampleBuffer.setToNull(); + return; + } + //NonPure normalPlayer->Spectator const bool isNotHearableInNonPureSpectator = clientDataDir->myClientData->isSpectating && ((clientData->isEnemyToPlayer && TFAR::config.get(Setting::spectatorNotHearEnemies)) || (!clientData->isEnemyToPlayer && !TFAR::config.get(Setting::spectatorCanHearFriendlies))); //Other player is also a spectator. So we always hear him without 3D positioning diff --git a/ts/src/settings.hpp b/ts/src/settings.hpp index 847bf69dd7..c7b8f1e6c7 100644 --- a/ts/src/settings.hpp +++ b/ts/src/settings.hpp @@ -27,7 +27,8 @@ XX(voiceCone, true), \ XX(allowDebugging, true), \ XX(noAutomoveSpectator, false), \ - XX(disableAutomaticMute, false) + XX(disableAutomaticMute, false), \ + XX(muteSpectators, false) #define EnumEntry(x,y) x #define EnumString(x,y) #x