2019-07-11 21:46:58 +02:00
# pragma semicolon 1
# include <sourcemod>
# include <sdktools>
# 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 ;
2019-07-18 12:45:02 +02:00
bool g_bBlockChat [ MAXPLAYERS + 1 ] = { false , . . . } ;
Handle g_hCookieBlockChat = null ;
2019-11-03 23:02:12 +01:00
# define NUMBEROFLENNIES 24
2019-07-11 21:46:58 +02:00
2019-11-03 23:02:12 +01:00
char g_cLennies [ NUMBEROFLENNIES ] [ ] = { " ( ͡° ͜ʖ ͡°) " , " ͜ʖ " , " (° ͜ʖ °) " , " ( ͝͠°͜ل͝͠°) " , " ( ͡° ͜ ͡°) " , " ( ͡°╭͜ʖ╮͡° ) " , " ( ͠° ͜ʖ ͡°) " , " ( ° ͜ʖ °) " , " (╯°□°)╯ " , " _(ツ)_ " , " _ツ_ " , " ( ̿°̿ ͜ل͜ ̿°̿ ) " , " ( ͡ " , " ( ͠ " , " ( ͝ " , " ( ° " , " (͡ " , " ಠ_ಠ " , " ͡° " , " °͡ " , " ʖ " , " ͡ " , " ͜ " , " っ " } ;
2019-07-11 21:46:58 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = " ChatFilter " ,
author = " Dogan " ,
description = " Makes it possible to selfmute several things in chat " ,
2019-07-18 12:45:02 +02:00
version = " 2.1.0 " ,
2019-07-11 21:46:58 +02:00
url = " "
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart ( )
{
2019-09-07 14:15:05 +02:00
RegConsoleCmd ( " sm_cf " , OnToggleSettings , " ChatFilter Settings " ) ;
RegConsoleCmd ( " sm_chatfilter " , OnToggleSettings , " ChatFilter Settings " ) ;
2019-07-11 21:46:58 +02:00
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 ) ;
2019-07-18 12:45:02 +02:00
RegConsoleCmd ( " sm_hide_chat " , OnToggleChat , " Toggle blocking other players Messages " ) ;
g_hCookieBlockChat = RegClientCookie ( " chat_blocked " , " are messages from others players blocked " , CookieAccess_Protected ) ;
2019-07-11 21:46:58 +02:00
SetCookieMenuItem ( MenuHandler_CookieMenu , 0 , " ChatFilter " ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2019-09-07 14:15:05 +02:00
public Action OnToggleSettings ( int client , int args )
{
ShowSettingsMenu ( client ) ;
return Plugin_Handled ;
}
2019-07-11 21:46:58 +02:00
public Action OnToggleLennies ( int client , int args )
{
ToggleLennies ( client ) ;
return Plugin_Handled ;
}
public Action OnToggleCommands ( int client , int args )
{
ToggleCommands ( client ) ;
return Plugin_Handled ;
}
2019-07-18 12:45:02 +02:00
public Action OnToggleChat ( int client , int args )
{
ToggleChat ( client ) ;
return Plugin_Handled ;
}
2019-07-11 21:46:58 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ShowSettingsMenu ( int client )
{
2019-07-18 12:45:02 +02:00
Menu menu = new Menu ( MenuHandler_MainMenu ) ;
menu . SetTitle ( " ChatFilter Settings " , client ) ;
2019-07-11 21:46:58 +02:00
2019-07-18 12:45:02 +02:00
char sBuffer [ 128 ] ;
2019-07-11 21:46:58 +02:00
2019-07-18 12:45:02 +02:00
Format ( sBuffer , sizeof ( sBuffer ) , " Hiding Lennies: %s " , g_bHideLennies [ client ] ? " Enabled " : " Disabled " ) ;
menu . AddItem ( " 0 " , sBuffer ) ;
2019-07-11 21:46:58 +02:00
2019-07-18 12:45:02 +02:00
Format ( sBuffer , sizeof ( sBuffer ) , " Hiding Commands: %s " , g_bBlockCommands [ client ] ? " Enabled " : " Disabled " ) ;
menu . AddItem ( " 1 " , sBuffer ) ;
2019-07-11 21:46:58 +02:00
2019-07-18 12:45:02 +02:00
Format ( sBuffer , sizeof ( sBuffer ) , " Hiding all Messages: %s " , g_bBlockChat [ client ] ? " Enabled " : " Disabled " ) ;
2019-07-18 12:54:57 +02:00
menu . AddItem ( " 2 " , sBuffer ) ;
2019-07-11 21:46:58 +02:00
2019-07-18 12:45:02 +02:00
menu . ExitBackButton = true ;
2019-07-11 21:46:58 +02:00
2019-07-18 12:45:02 +02:00
menu . Display ( client , MENU_TIME_FOREVER ) ;
2019-07-11 21:46:58 +02:00
}
//----------------------------------------------------------------------------------------------------
// 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 ) ;
2019-07-18 12:45:02 +02:00
case ( 2 ) : ToggleChat ( client ) ;
2019-07-11 21:46:58 +02:00
}
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 ) ;
2019-11-03 23:02:12 +01:00
bool blennies = false ;
2019-07-11 21:46:58 +02:00
for ( int i = 0 ; i < NUMBEROFLENNIES ; i + + )
{
2019-07-18 13:05:17 +02:00
if ( g_bHideLennies [ client ] & & StrContains ( message , g_cLennies [ i ] , false ) ! = - 1 )
2019-07-11 21:46:58 +02:00
{
2019-11-03 23:02:12 +01:00
blennies = true ;
2019-07-11 21:46:58 +02:00
}
}
2019-07-18 13:05:17 +02:00
2019-11-03 23:02:12 +01:00
if ( blennies | | ( g_bBlockCommands [ client ] & & ( index = = 0 | | index = = 7 ) ) | | g_bBlockChat [ client ] )
2019-07-18 13:05:17 +02:00
return Plugin_Handled ;
2019-07-11 21:46:58 +02:00
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. " ) ;
}
2019-07-18 12:45:02 +02:00
public void ToggleChat ( int client )
{
g_bBlockChat [ client ] = ! g_bBlockChat [ client ] ;
SetClientCookie ( client , g_hCookieBlockChat , g_bBlockChat [ client ] ? " 1 " : " " ) ;
CPrintToChat ( client , " {cyan}[ChatFilter] {white}%s " , g_bBlockChat [ client ] ? " Messages from all Players are now hidden. " : " Messages from all Players are not hidden anymore. " ) ;
}
2019-07-11 21:46:58 +02:00
//----------------------------------------------------------------------------------------------------
// 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 ;
}
2019-07-18 12:45:02 +02:00
GetClientCookie ( client , g_hCookieBlockChat , sBuffer , sizeof ( sBuffer ) ) ;
if ( sBuffer [ 0 ] ! = '\0' )
{
g_bBlockChat [ client ] = true ;
}
else
{
g_bBlockChat [ client ] = false ;
}
2019-07-11 21:46:58 +02:00
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect ( int client )
{
g_bHideLennies [ client ] = false ;
g_bBlockCommands [ client ] = false ;
2019-07-18 12:45:02 +02:00
g_bBlockChat [ client ] = false ;
2019-07-11 21:46:58 +02:00
}