SelfMute: add support for new voice extension IsClientTalking

This commit is contained in:
BotoX 2019-09-01 16:26:35 +02:00
parent a686c9cf1e
commit 589f13c2f3
3 changed files with 59 additions and 9 deletions

View File

@ -203,8 +203,6 @@ static int Subscribe_GameEvents_Replay(int Index, const char[] sEventName)
JSONObject jEventData = new JSONObject();
jEventData.SetString("name", sName);
char sBuf[MAX_NAME_LENGTH];
jEventData.GetString("name", sBuf, sizeof(sBuf));
jEventData.SetInt("index", client - 1);
jEventData.SetInt("userid", GetClientUserId(client));
jEventData.SetString("networkid", sSteamID);

View File

@ -12,15 +12,20 @@
#include <AdvancedTargeting>
#define REQUIRE_PLUGIN
#undef REQUIRE_EXTENSIONS
#tryinclude <voice>
#define REQUIRE_EXTENSIONS
#pragma newdecls required
bool g_Plugin_ccc = false;
bool g_Plugin_zombiereloaded = false;
bool g_Plugin_voiceannounce_ex = false;
bool g_Plugin_AdvancedTargeting = false;
bool g_Extension_Voice = false;
bool g_bIsProtoBuf = false;
#define PLUGIN_VERSION "2.2"
#define PLUGIN_VERSION "2.3"
public Plugin myinfo =
{
@ -86,12 +91,15 @@ public void OnAllPluginsLoaded()
g_Plugin_zombiereloaded = LibraryExists("zombiereloaded");
g_Plugin_voiceannounce_ex = LibraryExists("voiceannounce_ex");
g_Plugin_AdvancedTargeting = LibraryExists("AdvancedTargeting");
LogMessage("SelfMute capabilities:\nProtoBuf: %s\nCCC: %s\nZombieReloaded: %s\nVoiceAnnounce: %s\nAdvancedTargeting: %s",
g_Extension_Voice = LibraryExists("Voice");
LogMessage("SelfMute capabilities:\nProtoBuf: %s\nCCC: %s\nZombieReloaded: %s\nVoiceAnnounce: %s\nAdvancedTargeting: %s\nVoice: %s",
(g_bIsProtoBuf ? "yes" : "no"),
(g_Plugin_ccc ? "loaded" : "not loaded"),
(g_Plugin_zombiereloaded ? "loaded" : "not loaded"),
(g_Plugin_voiceannounce_ex ? "loaded" : "not loaded"),
(g_Plugin_AdvancedTargeting ? "loaded" : "not loaded"));
(g_Plugin_AdvancedTargeting ? "loaded" : "not loaded"),
(g_Extension_Voice ? "loaded" : "not loaded"));
}
public void OnClientPutInServer(int client)
@ -632,6 +640,21 @@ public Action Command_CheckMutes(int client, int args)
return Plugin_Handled;
}
stock bool _IsClientSpeaking(int client)
{
#if defined _voiceannounceex_included_
if(g_Plugin_voiceannounce_ex)
return IsClientSpeaking(client);
#endif
#if defined _voice_included
if(g_Extension_Voice)
return IsClientTalking(client);
#endif
return false;
}
/*
* MENU
*/
@ -642,14 +665,12 @@ void DisplayMuteMenu(int client)
int[] aClients = new int[MaxClients + 1];
#if defined _voiceannounceex_included_
if(g_Plugin_voiceannounce_ex)
{
// Count talking players and insert id's into aClients array
int CurrentlyTalking = 0;
for(int i = 1; i <= MaxClients; i++)
{
if(i != client && IsClientInGame(i) && !IsFakeClient(i) && IsClientSpeaking(i))
if(i != client && IsClientInGame(i) && !IsFakeClient(i) && _IsClientSpeaking(i))
aClients[CurrentlyTalking++] = i;
}
@ -676,7 +697,6 @@ void DisplayMuteMenu(int client)
menu.AddItem("", "", ITEMDRAW_RAWLINE);
}
}
#endif
menu.AddItem("@all", "Everyone");
menu.AddItem("@spec", "Spectators");

32
includes/voice.inc Normal file
View File

@ -0,0 +1,32 @@
#if defined _voice_included
#endinput
#endif
#define _voice_included
native bool IsClientTalking(int client);
/**
* Do not edit below this line!
*/
public Extension __ext_voice =
{
name = "Voice",
file = "Voice.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_voice_SetNTVOptional()
{
MarkNativeAsOptional("IsClientTalking");
}
#endif