SelfMute: temporary perma sm torch

will improve at some point, just dont want this to get lost meanwhile
This commit is contained in:
Dogan 2019-11-17 23:09:37 +01:00
parent cd9531dff4
commit ca7fec3bcf

View File

@ -4,6 +4,7 @@
#include <sdktools>
#include <adminmenu>
#include <cstrike>
#include <clientprefs>
#undef REQUIRE_PLUGIN
#include <ccc>
@ -25,7 +26,9 @@ bool g_Plugin_AdvancedTargeting = false;
bool g_Extension_Voice = false;
bool g_bIsProtoBuf = false;
#define PLUGIN_VERSION "2.3"
Handle g_hCookieTorchMuted = null;
#define PLUGIN_VERSION "2.4"
public Plugin myinfo =
{
@ -83,6 +86,8 @@ public void OnPluginStart()
SetFailState("This game doesn't support SendAudio user messages.");
HookUserMessage(SendAudio, Hook_UserMessageSendAudio, true);
g_hCookieTorchMuted = RegClientCookie("torch_muted", "is torch muted", CookieAccess_Protected);
}
public void OnAllPluginsLoaded()
@ -134,6 +139,8 @@ public void OnClientPutInServer(int client)
UpdateSpecialMutesOtherClients(client);
UpdateIgnored();
GetCookiesForTorch(client);
}
public void OnClientDisconnect(int client)
@ -154,6 +161,23 @@ public void OnClientDisconnect(int client)
UpdateIgnored();
}
public void GetCookiesForTorch(int client)
{
char sBuffer[2];
GetClientCookie(client, g_hCookieTorchMuted, sBuffer, sizeof(sBuffer));
if(sBuffer[0] != '\0')
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsClientSourceTV(i))
Ignore(client, i);
}
}
UpdateIgnored();
}
public void Event_Round(Handle event, const char[] name, bool dontBroadcast)
{
for(int i = 1; i <= MaxClients; i++)
@ -394,7 +418,7 @@ bool UnMuteSpecial(int client, char[] Argument)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
if(IsClientInGame(i) && !IsClientSourceTV(i))
UnIgnore(client, i);
PrintToChat(client, "\x04[Self-Mute]\x01 You have self-unmuted:\x04 all players");
@ -496,6 +520,14 @@ public Action Command_SelfMute(int client, int args)
return Plugin_Handled;
}
if(IsClientSourceTV(aTargetList[0]))
{
Ignore(client, aTargetList[0]);
SetClientCookie(client, g_hCookieTorchMuted, "1");
PrintToChat(client, "\x04[Self-Mute]\x01 You have permanently self-muted:\x04 %s", sTargetName);
return Plugin_Handled;
}
if(GetExempt(client, aTargetList[0]))
{
UnExempt(client, aTargetList[0]);
@ -572,6 +604,14 @@ public Action Command_SelfUnMute(int client, int args)
return Plugin_Handled;
}
if(IsClientSourceTV(aTargetList[0]))
{
UnIgnore(client, aTargetList[0]);
SetClientCookie(client, g_hCookieTorchMuted, "");
PrintToChat(client, "\x04[Self-Mute]\x01 You have permanently self-unmuted:\x04 %s", sTargetName);
return Plugin_Handled;
}
if(!GetIgnored(client, aTargetList[0]))
{
Exempt(client, aTargetList[0]);
@ -791,8 +831,17 @@ public int MenuHandler_MuteMenu(Menu menu, MenuAction action, int param1, int pa
if(GetIgnored(param1, client))
{
UnIgnore(param1, client);
PrintToChat(param1, "\x04[Self-Mute]\x01 You have self-unmuted:\x04 %N", client);
if(IsClientSourceTV(client))
{
UnIgnore(param1, client);
SetClientCookie(param1, g_hCookieTorchMuted, "");
PrintToChat(param1, "\x04[Self-Mute]\x01 You have permanently self-unmuted:\x04 %N", client);
}
else
{
UnIgnore(param1, client);
PrintToChat(param1, "\x04[Self-Mute]\x01 You have self-unmuted:\x04 %N", client);
}
}
else if(GetExempt(param1, client))
{
@ -801,8 +850,17 @@ public int MenuHandler_MuteMenu(Menu menu, MenuAction action, int param1, int pa
}
else
{
Ignore(param1, client);
PrintToChat(param1, "\x04[Self-Mute]\x01 You have self-muted:\x04 %N", client);
if(IsClientSourceTV(client))
{
Ignore(param1, client);
SetClientCookie(param1, g_hCookieTorchMuted, "1");
PrintToChat(param1, "\x04[Self-Mute]\x01 You have permanently self-muted:\x04 %N", client);
}
else
{
Ignore(param1, client);
PrintToChat(param1, "\x04[Self-Mute]\x01 You have self-muted:\x04 %N", client);
}
}
menu.DisplayAt(param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
return 0;
@ -1014,8 +1072,17 @@ public int MenuHandler_UnMuteMenu(Menu menu, MenuAction action, int param1, int
if(GetIgnored(param1, client))
{
UnIgnore(param1, client);
PrintToChat(param1, "\x04[Self-Mute]\x01 You have self-unmuted:\x04 %N", client);
if(IsClientSourceTV(client))
{
UnIgnore(param1, client);
SetClientCookie(param1, g_hCookieTorchMuted, "");
PrintToChat(param1, "\x04[Self-Mute]\x01 You have permanently self-unmuted:\x04 %N", client);
}
else
{
UnIgnore(param1, client);
PrintToChat(param1, "\x04[Self-Mute]\x01 You have self-unmuted:\x04 %N", client);
}
}
else if(GetExempt(param1, client))
{