add nade mute only
pretty sure it works
This commit is contained in:
parent
7f5ec83506
commit
5ceea87a00
@ -10,8 +10,10 @@
|
||||
|
||||
bool g_bStopRadioSounds[MAXPLAYERS+1] = { false, ... };
|
||||
bool g_bStopRadioSoundsHooked = false;
|
||||
bool g_bStopNadeSounds[MAXPLAYERS+1] = { false, ...};
|
||||
|
||||
Handle g_hCookieStopRadio = null;
|
||||
Handle g_hCookieStopNade = null;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@ -36,8 +38,10 @@ public void OnPluginStart()
|
||||
|
||||
RegConsoleCmd("sm_smradio", ToggleSelfMuteRadio, "Toggle Radio Self Mute");
|
||||
//RegConsoleCmd("sm_radio", ToggleSelfMuteRadio, "Toggle Radio Self Mute"); //GFL only
|
||||
RegConsoleCmd("sm_smradio_nades", ToggleSelfMuteNade, "Toggle only Radio 'Fire in the hole' Self Mute");
|
||||
|
||||
g_hCookieStopRadio = RegClientCookie("radio_blocked", "is the radio blocked", CookieAccess_Protected);
|
||||
g_hCookieStopNade = RegClientCookie("nades_blocked", "is the 'fire in the hole' radio blocked", CookieAccess_Protected);
|
||||
|
||||
HookUserMessage(RadioText, Hook_RadioText, true);
|
||||
HookUserMessage(SendAudio, Hook_SendAudio, true);
|
||||
@ -48,6 +52,18 @@ public Action Hook_RadioText(UserMsg msg_id, Handle bf, const int[] players, int
|
||||
if(!g_bStopRadioSoundsHooked)
|
||||
return Plugin_Continue;
|
||||
|
||||
int dest = BfReadByte(bf);
|
||||
int client = BfReadByte(bf);
|
||||
|
||||
char sSoundType[128];
|
||||
BfReadString(bf, sSoundType, sizeof(sSoundType), false);
|
||||
|
||||
char sSoundName[128];
|
||||
BfReadString(bf, sSoundName, sizeof(sSoundName), false);
|
||||
|
||||
char sSoundFile[128];
|
||||
BfReadString(bf, sSoundFile, sizeof(sSoundFile), false);
|
||||
|
||||
// Check which clients need to be excluded.
|
||||
int[] newPlayers = new int[playersNum];
|
||||
int newPlayersNum = 0;
|
||||
@ -56,7 +72,7 @@ public Action Hook_RadioText(UserMsg msg_id, Handle bf, const int[] players, int
|
||||
{
|
||||
int player = players[i];
|
||||
|
||||
if(IsClientInGame(player) && !g_bStopRadioSounds[player])
|
||||
if(IsClientInGame(player) && !g_bStopRadioSounds[player] && !(g_bStopNadeSounds[player] && StrContains(sSoundFile, "hole", false) != -1))
|
||||
{
|
||||
newPlayers[newPlayersNum++] = player;
|
||||
}
|
||||
@ -73,18 +89,6 @@ public Action Hook_RadioText(UserMsg msg_id, Handle bf, const int[] players, int
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int dest = BfReadByte(bf);
|
||||
int client = BfReadByte(bf);
|
||||
|
||||
char sSoundType[128];
|
||||
BfReadString(bf, sSoundType, sizeof(sSoundType), false);
|
||||
|
||||
char sSoundName[128];
|
||||
BfReadString(bf, sSoundName, sizeof(sSoundName), false);
|
||||
|
||||
char sSoundFile[128];
|
||||
BfReadString(bf, sSoundFile, sizeof(sSoundFile), false);
|
||||
|
||||
DataPack pack = new DataPack();
|
||||
pack.WriteString(sSoundType);
|
||||
pack.WriteString(sSoundName);
|
||||
@ -154,6 +158,9 @@ public Action Hook_SendAudio(UserMsg msg_id, Handle bf, const int[] players, int
|
||||
if(!g_bStopRadioSoundsHooked)
|
||||
return Plugin_Continue;
|
||||
|
||||
char sSoundFile[128];
|
||||
BfReadString(bf, sSoundFile, sizeof(sSoundFile), false);
|
||||
|
||||
// Check which clients need to be excluded.
|
||||
int[] newPlayers = new int[playersNum];
|
||||
int newPlayersNum = 0;
|
||||
@ -162,7 +169,7 @@ public Action Hook_SendAudio(UserMsg msg_id, Handle bf, const int[] players, int
|
||||
{
|
||||
int player = players[i];
|
||||
|
||||
if(IsClientInGame(player) && !g_bStopRadioSounds[player])
|
||||
if(IsClientInGame(player) && !g_bStopRadioSounds[player] && !(g_bStopNadeSounds[player] && StrContains(sSoundFile, "hole", false) != -1))
|
||||
{
|
||||
newPlayers[newPlayersNum++] = player;
|
||||
}
|
||||
@ -179,9 +186,6 @@ public Action Hook_SendAudio(UserMsg msg_id, Handle bf, const int[] players, int
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sSoundFile[128];
|
||||
BfReadString(bf, sSoundFile, sizeof(sSoundFile), false);
|
||||
|
||||
DataPack pack = new DataPack();
|
||||
pack.WriteString(sSoundFile);
|
||||
pack.WriteCell(newPlayersNum);
|
||||
@ -233,17 +237,36 @@ public void OnSendAudio(DataPack pack)
|
||||
public Action ToggleSelfMuteRadio(int client, int args)
|
||||
{
|
||||
g_bStopRadioSounds[client] = !g_bStopRadioSounds[client];
|
||||
CheckSelfMuteRadioHooks();
|
||||
CheckHooks();
|
||||
|
||||
if(g_bStopRadioSounds[client])
|
||||
{
|
||||
ReplyToCommand(client, "You blocked Radio Messages and Sound");
|
||||
ReplyToCommand(client, "You blocked all Radio Messages and Sound");
|
||||
SetClientCookie(client, g_hCookieStopRadio, "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToCommand(client, "You unblocked Radio Messages and Sound");
|
||||
ReplyToCommand(client, "You unblocked all Radio Messages and Sound");
|
||||
SetClientCookie(client, g_hCookieStopRadio, "");
|
||||
g_bStopNadeSounds[client] = false;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action ToggleSelfMuteNade(int client, int args)
|
||||
{
|
||||
g_bStopNadeSounds[client] = !g_bStopNadeSounds[client];
|
||||
CheckHooks();
|
||||
|
||||
if(g_bStopNadeSounds[client])
|
||||
{
|
||||
ReplyToCommand(client, "You blocked 'Fire in the Hole' Radio Messages and Sound");
|
||||
SetClientCookie(client, g_hCookieStopNade, "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToCommand(client, "You unblocked 'Fire in the Hole' Radio Messages and Sound");
|
||||
SetClientCookie(client, g_hCookieStopNade, "");
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -263,21 +286,34 @@ public void OnClientCookiesCached(int client)
|
||||
{
|
||||
g_bStopRadioSounds[client] = false;
|
||||
}
|
||||
|
||||
GetClientCookie(client, g_hCookieStopRadio, sBuffer, sizeof(sBuffer));
|
||||
|
||||
if(sBuffer[0] != '\0')
|
||||
{
|
||||
g_bStopNadeSounds[client] = true;
|
||||
g_bStopRadioSoundsHooked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bStopNadeSounds[client] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_bStopRadioSounds[client] = false;
|
||||
CheckSelfMuteRadioHooks();
|
||||
g_bStopNadeSounds[client] = false;
|
||||
CheckHooks();
|
||||
}
|
||||
|
||||
public void CheckSelfMuteRadioHooks()
|
||||
public void CheckHooks()
|
||||
{
|
||||
bool bShouldHook = false;
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(g_bStopRadioSounds[i])
|
||||
if(g_bStopRadioSounds[i] || g_bStopNadeSounds[i])
|
||||
{
|
||||
bShouldHook = true;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user