New Plugin: ChatFilter
includes AntiLenny + new AntiCommand
This commit is contained in:
		
							parent
							
								
									7e3d1258fb
								
							
						
					
					
						commit
						9d4e101de9
					
				
							
								
								
									
										201
									
								
								ChatFilter/scripting/ChatFilter.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										201
									
								
								ChatFilter/scripting/ChatFilter.sp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,201 @@
 | 
			
		||||
#pragma semicolon 1
 | 
			
		||||
 | 
			
		||||
#include <sourcemod>
 | 
			
		||||
#include <sdktools>
 | 
			
		||||
#include <zombiereloaded>
 | 
			
		||||
#include <cstrike>
 | 
			
		||||
#include <ccc>
 | 
			
		||||
#include <multicolors>
 | 
			
		||||
#include <clientprefs>
 | 
			
		||||
 | 
			
		||||
bool g_bHideLennies[MAXPLAYERS + 1] = { false, ... };
 | 
			
		||||
Handle g_hCookieHideLennies = null;
 | 
			
		||||
 | 
			
		||||
bool g_bBlockCommands[MAXPLAYERS + 1] = { false, ... };
 | 
			
		||||
Handle g_hCookieBlockCommands = null;
 | 
			
		||||
 | 
			
		||||
#define NUMBEROFLENNIES 23
 | 
			
		||||
 | 
			
		||||
char g_cLennies[NUMBEROFLENNIES][] = {"( ͡° ͜ʖ ͡°)", "͜ʖ", "(° ͜ʖ °)", "( ͝͠°͜ل͝͠°)", "( ͡° ͜ ͡°)", "( ͡°╭͜ʖ╮͡° )", "( ͠° ͜ʖ ͡°)", "( ° ͜ʖ °)", "(╯°□°)╯", "_(ツ)_", "_ツ_", "( ̿°̿ ͜ل͜ ̿°̿ )", "( ͡", "( ͠", "( ͝", "( °", "(͡", "ಠ_ಠ", "͡°", "°͡", "ʖ", "͡", "͜"};
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public Plugin myinfo =
 | 
			
		||||
{
 | 
			
		||||
	name = "ChatFilter",
 | 
			
		||||
	author = "Dogan",
 | 
			
		||||
	description = "Makes it possible to selfmute several things in chat",
 | 
			
		||||
	version = "2.0.0",
 | 
			
		||||
	url = ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void OnPluginStart()
 | 
			
		||||
{
 | 
			
		||||
	RegConsoleCmd("sm_hide_lennies", OnToggleLennies, "Toggle blocking Lennies");
 | 
			
		||||
	g_hCookieHideLennies = RegClientCookie("lennies_blocked", "are lennies blocked", CookieAccess_Protected);
 | 
			
		||||
 | 
			
		||||
	RegConsoleCmd("sm_hide_commands", OnToggleCommands, "Toggle blocking Commands");
 | 
			
		||||
	g_hCookieBlockCommands = RegClientCookie("commands_blocked", "are commands blocked", CookieAccess_Protected);
 | 
			
		||||
 | 
			
		||||
	SetCookieMenuItem(MenuHandler_CookieMenu, 0, "ChatFilter");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public Action OnToggleLennies(int client, int args)
 | 
			
		||||
{
 | 
			
		||||
	ToggleLennies(client);
 | 
			
		||||
	return Plugin_Handled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public Action OnToggleCommands(int client, int args)
 | 
			
		||||
{
 | 
			
		||||
	ToggleCommands(client);
 | 
			
		||||
	return Plugin_Handled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void ShowSettingsMenu(int client)
 | 
			
		||||
{
 | 
			
		||||
    Menu menu = new Menu(MenuHandler_MainMenu);
 | 
			
		||||
 | 
			
		||||
    menu.SetTitle("ChatFilter Settings", client);
 | 
			
		||||
 | 
			
		||||
    char sBuffer[128];
 | 
			
		||||
 | 
			
		||||
    Format(sBuffer, sizeof(sBuffer), "Hiding Lennies: %s", g_bHideLennies[client] ? "Enabled" : "Disabled");
 | 
			
		||||
    menu.AddItem("0", sBuffer);
 | 
			
		||||
 | 
			
		||||
    Format(sBuffer, sizeof(sBuffer), "Hiding Commands: %s", g_bBlockCommands[client] ? "Enabled" : "Disabled");
 | 
			
		||||
    menu.AddItem("1", sBuffer);
 | 
			
		||||
 | 
			
		||||
    menu.ExitBackButton = true;
 | 
			
		||||
 | 
			
		||||
    menu.Display(client, MENU_TIME_FOREVER);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
 | 
			
		||||
{
 | 
			
		||||
	switch(action)
 | 
			
		||||
	{
 | 
			
		||||
		case(CookieMenuAction_DisplayOption):
 | 
			
		||||
		{
 | 
			
		||||
			Format(buffer, maxlen, "ChatFilter", client);
 | 
			
		||||
		}
 | 
			
		||||
		case(CookieMenuAction_SelectOption):
 | 
			
		||||
		{
 | 
			
		||||
			ShowSettingsMenu(client);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
 | 
			
		||||
{
 | 
			
		||||
	switch(action)
 | 
			
		||||
	{
 | 
			
		||||
		case(MenuAction_Select):
 | 
			
		||||
		{
 | 
			
		||||
			switch(selection)
 | 
			
		||||
			{
 | 
			
		||||
				case(0): ToggleLennies(client);
 | 
			
		||||
				case(1): ToggleCommands(client);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			ShowSettingsMenu(client);
 | 
			
		||||
		}
 | 
			
		||||
		case(MenuAction_Cancel):
 | 
			
		||||
		{
 | 
			
		||||
			ShowCookieMenu(client);
 | 
			
		||||
		}
 | 
			
		||||
		case(MenuAction_End):
 | 
			
		||||
		{
 | 
			
		||||
			delete menu;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public Action CCC_OnChatMessage(int client, int author, const char[] message)
 | 
			
		||||
{
 | 
			
		||||
	int index = FindCharInString(message, '!', false);
 | 
			
		||||
 | 
			
		||||
	for(int i = 0; i < NUMBEROFLENNIES; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if((g_bHideLennies[client] && StrContains(message, g_cLennies[i], false) != -1) || (g_bBlockCommands[client] && (index == 0 || index == 7)))
 | 
			
		||||
		{
 | 
			
		||||
			return Plugin_Handled;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return Plugin_Continue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void ToggleLennies(int client)
 | 
			
		||||
{
 | 
			
		||||
	g_bHideLennies[client] = !g_bHideLennies[client];
 | 
			
		||||
 | 
			
		||||
	SetClientCookie(client, g_hCookieHideLennies, g_bHideLennies[client] ? "1" : "");
 | 
			
		||||
	CPrintToChat(client, "{cyan}[ChatFilter] {white}%s", g_bHideLennies[client] ? "Lennies are now hidden." : "Lennies are not hidden anymore.");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void ToggleCommands(int client)
 | 
			
		||||
{
 | 
			
		||||
	g_bBlockCommands[client] = !g_bBlockCommands[client];
 | 
			
		||||
 | 
			
		||||
	SetClientCookie(client, g_hCookieBlockCommands, g_bBlockCommands[client] ? "1" : "");
 | 
			
		||||
	CPrintToChat(client, "{cyan}[ChatFilter] {white}%s", g_bBlockCommands[client] ? "Commands are now hidden." : "Commands are not hidden anymore.");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void OnClientCookiesCached(int client)
 | 
			
		||||
{
 | 
			
		||||
	char sBuffer[2];
 | 
			
		||||
 | 
			
		||||
	GetClientCookie(client, g_hCookieHideLennies, sBuffer, sizeof(sBuffer));
 | 
			
		||||
	if(sBuffer[0] != '\0')
 | 
			
		||||
	{
 | 
			
		||||
		g_bHideLennies[client] = true;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		g_bHideLennies[client] = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	GetClientCookie(client, g_hCookieBlockCommands, sBuffer, sizeof(sBuffer));
 | 
			
		||||
	if(sBuffer[0] != '\0')
 | 
			
		||||
	{
 | 
			
		||||
		g_bBlockCommands[client] = true;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		g_bBlockCommands[client] = false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void OnClientDisconnect(int client)
 | 
			
		||||
{
 | 
			
		||||
	g_bHideLennies[client] = false;
 | 
			
		||||
	g_bBlockCommands[client] = false;
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user