Skip to content

Commit

Permalink
Spectator mute (michail-nikolaev#1567)
Browse files Browse the repository at this point in the history
* Add settings, strings and auto send to plugin

* spectator mute - plugin part
  • Loading branch information
ilbinek authored May 15, 2024
1 parent 83b85df commit ce23ed8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
10 changes: 9 additions & 1 deletion addons/core/functions/fnc_initCBASettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand Down
1 change: 1 addition & 0 deletions addons/core/functions/plugin/fnc_sendPluginConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions addons/core/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,14 @@
<Czech>Nevynucovat přesun do kanálu TFAR v režimu diváka</Czech>
<Russian>Не перемещать принудительно в канал TFAR в режиме наблюдателя</Russian>
</Key>
<Key ID="STR_TFAR_SETTINGS_muteSpectators">
<English>Mute other spectators</English>
<Czech>Ztišit ostatní diváky</Czech>
</Key>
<Key ID="STR_TFAR_SETTINGS_muteSpectators_desc">
<English>When spectating, mute other spectators and listen to alive players only</English>
<Czech>Při sledování ztišit ostatní diváky zatímco lze poslouchat hráče kteří jsou stále živí</Czech>
</Key>
<Key ID="STR_TFAR_SETTINGS_noTSNotConnectedHint">
<English>Hide "Not connected" message</English>
<German>Verstecke "Not connected" message</German>
Expand Down
7 changes: 7 additions & 0 deletions ts/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(Setting::muteSpectators)) && clientDataDir->myClientData->isSpectating && isSpectator) {
sampleBuffer.setToNull();
return;
}

//NonPure normalPlayer->Spectator
const bool isNotHearableInNonPureSpectator = clientDataDir->myClientData->isSpectating && ((clientData->isEnemyToPlayer && TFAR::config.get<bool>(Setting::spectatorNotHearEnemies)) || (!clientData->isEnemyToPlayer && !TFAR::config.get<bool>(Setting::spectatorCanHearFriendlies)));
//Other player is also a spectator. So we always hear him without 3D positioning
Expand Down
3 changes: 2 additions & 1 deletion ts/src/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce23ed8

Please sign in to comment.