This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Add Filter Special Characters (!#$%*) Functionality In This Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
T0FF
Member
Join Date: Oct 2014
Location: Asia
Old 07-23-2015 , 14:08   Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #1

This is Chat_Filter/Swearing plugin, i want small edition in this.
It filters/blocks swearing words successfully. but when the swearing word is used with special characters then it doesn't filter/block swear word. Edition of all special characters to be filtered when used.
For example; s-w-e-a-r or s.w.e.a.r
I just need help of someone who can edit it for me. Will be highly obliged!


Plugin:
Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Chat Filter"
#define VERSION "1.2"
#define AUTHOR "RateX"

#define MAX_BL		500	// Increase this number to increase max blacklisted words
#define MAX_WL		500 	// Increase this number to increase max whitelisted words

new g_blacknum, g_whitenum, BAD_WORDS[MAX_BL][64], GOOD_WORDS[MAX_WL][64]
new white[128][128], said[512], pos, bad[64], len, good[64], wnum, wlen[128], block

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
    
	register_clcmd("say ", "ChatGlobalCommand", ADMIN_IMMUNITY, "Filter Global Chat")
	register_clcmd("say_team ", "ChatTeamCommand", ADMIN_IMMUNITY, "Filter Team Chat")
}

public plugin_precache()
{
	new configsdir[64], path[132]
	get_configsdir(configsdir, charsmax(configsdir))
	
	// Load blacklisted words
	formatex(path, charsmax(path), "%s/blacklistwords.ini", configsdir)	
	new file = fopen(path, "rt")
	if(!file)
	{
		server_print("Could not find the blacklistwords.ini file!")
		return PLUGIN_HANDLED
	}
	new linedata[512]
	
	while(!feof(file))
	{
		// Read one line at a time
		fgets(file, linedata, charsmax(linedata))

		// Replace newlines with a null character to prevent headaches
		replace(linedata, charsmax(linedata), "^n", "")
			
		// Blank line or comment
		if (!linedata[0] || linedata[0] == ';') 
			continue
			
		parse(linedata, BAD_WORDS[g_blacknum], 63)
		g_blacknum++
	}
	fclose(file)
	// Load whitelisted words
	formatex(path, charsmax(path), "%s/whitelistwords.ini", configsdir)	
	file = fopen(path, "rt")
	if(!file)
	{
		server_print("Could not find the whitelistwords.ini file!")
		return PLUGIN_HANDLED
	}
	
	while(!feof(file))
	{
		// Read one line at a time
		fgets(file, linedata, charsmax(linedata))

		// Replace newlines with a null character to prevent headaches
		replace(linedata, charsmax(linedata), "^n", "")
			
		// Blank line or comment
		if (!linedata[0] || linedata[0] == ';') 
			continue
			
		parse(linedata, GOOD_WORDS[g_whitenum], 63)
		g_whitenum++
	}
	fclose(file)
	return PLUGIN_CONTINUE
}

public ChatGlobalCommand(id, level, cid)
{
	if(cmd_access(id, level, cid, 1))
		return PLUGIN_CONTINUE

	read_args(said, charsmax(said))
	block = 0
	wnum = 0
	
	// Check for whitelisted words(case ignored) and hide them
	for(new j = 0; j < g_whitenum; j++)
	{
		while((pos = containi(said, GOOD_WORDS[j])) != -1)
		{
			wnum++
			wlen[wnum] = strlen(GOOD_WORDS[j])
			copy(white[wnum], wlen[wnum], said[pos])
			formatex(good, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜÜÜÜÜÜÜÜÜ")
			replace(said, charsmax(said), white[wnum], good)	
		}	
	}
	// Check for blacklisted words(case ignored) and replace them
	for(new i = 0; i < g_blacknum; i++)
	{
		while((pos = containi(said, BAD_WORDS[i])) != -1)
		{
			len = strlen(BAD_WORDS[i])
			copy(bad, len, said[pos])
			formatex(good, len, "%s", "********************************************")
			replace_all(said, charsmax(said), bad, good)   
			if(!block)
				block = 1
		}
	}
	
	if(block)
	{
		// Restore the whitelisted words
		while(wnum)
		{
			pos = containi(said, "äëï")
			copy(good, wlen[wnum], white[wnum])
			formatex(bad, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜÜÜÜÜÜÜÜÜ")
			replace(said, charsmax(said), bad, good)
			wnum--
		}
		client_cmd(id, "say %s", said)
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}

public ChatTeamCommand(id, level, cid)
{
	if(cmd_access(id, level, cid, 1))
		return PLUGIN_CONTINUE
		
	read_args(said, charsmax(said))
	block = 0
	wnum = 0
	
	// Check for whitelisted words(case ignored) and hide them
	for(new j = 0; j < g_whitenum; j++)
	{
		while((pos = containi(said, GOOD_WORDS[j])) != -1)
		{
			wnum++
			wlen[wnum] = strlen(GOOD_WORDS[j])
			copy(white[wnum], wlen[wnum], said[pos])
			formatex(good, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜ")
			replace(said, charsmax(said), white[wnum], good)	
		}	
	}
	// Check for blacklisted words(case ignored) and replace them
	for(new i = 0; i < g_blacknum; i++)
	{
		while((pos = containi(said, BAD_WORDS[i])) != -1)
		{
			len = strlen(BAD_WORDS[i])
			copy(bad, len, said[pos])
			formatex(good, len, "%s", "********************************************")
			replace_all(said, charsmax(said), bad, good)   
			if(!block)
				block = 1
		}
	}
	
	if(block)
	{
		// Restore the whitelisted words
		while(wnum)
		{
			pos = containi(said, "äëï")
			copy(good, wlen[wnum], white[wnum])
			format(bad, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜ")
			replace(said, charsmax(said), bad, good)
			wnum--
		}
		client_cmd(id, "say_team %s", said)
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
T0FF is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 07-23-2015 , 17:48   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #2

Quote:
Originally Posted by T0FF View Post
This is Chat_Filter/Swearing plugin, i want small edition in this.
It filters/blocks swearing words successfully. but when the swearing word is used with special characters then it doesn't filter/block swear word. Edition of all special characters to be filtered when used.
For example; s-w-e-a-r or s.w.e.a.r
I just need help of someone who can edit it for me. Will be highly obliged!


Plugin:
Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Chat Filter"
#define VERSION "1.2"
#define AUTHOR "RateX"

#define MAX_BL		500	// Increase this number to increase max blacklisted words
#define MAX_WL		500 	// Increase this number to increase max whitelisted words

new g_blacknum, g_whitenum, BAD_WORDS[MAX_BL][64], GOOD_WORDS[MAX_WL][64]
new white[128][128], said[512], pos, bad[64], len, good[64], wnum, wlen[128], block

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
    
	register_clcmd("say ", "ChatGlobalCommand", ADMIN_IMMUNITY, "Filter Global Chat")
	register_clcmd("say_team ", "ChatTeamCommand", ADMIN_IMMUNITY, "Filter Team Chat")
}

public plugin_precache()
{
	new configsdir[64], path[132]
	get_configsdir(configsdir, charsmax(configsdir))
	
	// Load blacklisted words
	formatex(path, charsmax(path), "%s/blacklistwords.ini", configsdir)	
	new file = fopen(path, "rt")
	if(!file)
	{
		server_print("Could not find the blacklistwords.ini file!")
		return PLUGIN_HANDLED
	}
	new linedata[512]
	
	while(!feof(file))
	{
		// Read one line at a time
		fgets(file, linedata, charsmax(linedata))

		// Replace newlines with a null character to prevent headaches
		replace(linedata, charsmax(linedata), "^n", "")
			
		// Blank line or comment
		if (!linedata[0] || linedata[0] == ';') 
			continue
			
		parse(linedata, BAD_WORDS[g_blacknum], 63)
		g_blacknum++
	}
	fclose(file)
	// Load whitelisted words
	formatex(path, charsmax(path), "%s/whitelistwords.ini", configsdir)	
	file = fopen(path, "rt")
	if(!file)
	{
		server_print("Could not find the whitelistwords.ini file!")
		return PLUGIN_HANDLED
	}
	
	while(!feof(file))
	{
		// Read one line at a time
		fgets(file, linedata, charsmax(linedata))

		// Replace newlines with a null character to prevent headaches
		replace(linedata, charsmax(linedata), "^n", "")
			
		// Blank line or comment
		if (!linedata[0] || linedata[0] == ';') 
			continue
			
		parse(linedata, GOOD_WORDS[g_whitenum], 63)
		g_whitenum++
	}
	fclose(file)
	return PLUGIN_CONTINUE
}

public ChatGlobalCommand(id, level, cid)
{
	if(cmd_access(id, level, cid, 1))
		return PLUGIN_CONTINUE

	read_args(said, charsmax(said))
	block = 0
	wnum = 0
	
	// Check for whitelisted words(case ignored) and hide them
	for(new j = 0; j < g_whitenum; j++)
	{
		while((pos = containi(said, GOOD_WORDS[j])) != -1)
		{
			wnum++
			wlen[wnum] = strlen(GOOD_WORDS[j])
			copy(white[wnum], wlen[wnum], said[pos])
			formatex(good, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜÜÜÜÜÜÜÜÜ")
			replace(said, charsmax(said), white[wnum], good)	
		}	
	}
	// Check for blacklisted words(case ignored) and replace them
	for(new i = 0; i < g_blacknum; i++)
	{
		while((pos = containi(said, BAD_WORDS[i])) != -1)
		{
			len = strlen(BAD_WORDS[i])
			copy(bad, len, said[pos])
			formatex(good, len, "%s", "********************************************")
			replace_all(said, charsmax(said), bad, good)   
			if(!block)
				block = 1
		}
	}
	
	if(block)
	{
		// Restore the whitelisted words
		while(wnum)
		{
			pos = containi(said, "äëï")
			copy(good, wlen[wnum], white[wnum])
			formatex(bad, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜÜÜÜÜÜÜÜÜ")
			replace(said, charsmax(said), bad, good)
			wnum--
		}
		client_cmd(id, "say %s", said)
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}

public ChatTeamCommand(id, level, cid)
{
	if(cmd_access(id, level, cid, 1))
		return PLUGIN_CONTINUE
		
	read_args(said, charsmax(said))
	block = 0
	wnum = 0
	
	// Check for whitelisted words(case ignored) and hide them
	for(new j = 0; j < g_whitenum; j++)
	{
		while((pos = containi(said, GOOD_WORDS[j])) != -1)
		{
			wnum++
			wlen[wnum] = strlen(GOOD_WORDS[j])
			copy(white[wnum], wlen[wnum], said[pos])
			formatex(good, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜ")
			replace(said, charsmax(said), white[wnum], good)	
		}	
	}
	// Check for blacklisted words(case ignored) and replace them
	for(new i = 0; i < g_blacknum; i++)
	{
		while((pos = containi(said, BAD_WORDS[i])) != -1)
		{
			len = strlen(BAD_WORDS[i])
			copy(bad, len, said[pos])
			formatex(good, len, "%s", "********************************************")
			replace_all(said, charsmax(said), bad, good)   
			if(!block)
				block = 1
		}
	}
	
	if(block)
	{
		// Restore the whitelisted words
		while(wnum)
		{
			pos = containi(said, "äëï")
			copy(good, wlen[wnum], white[wnum])
			format(bad, wlen[wnum], "%s", "äëïöüÇÑáéíóúÁÉÍÓÚñçÄËÏÖÜ")
			replace(said, charsmax(said), bad, good)
			wnum--
		}
		client_cmd(id, "say_team %s", said)
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
PHP Code:
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

#include <amxmisc>

#pragma tabsize 0

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

new const     PLUGIN []        =    "Anti Chat",
                    
VERSION []    =    "1.0",
                    
AUTHOR []    =    "Syturio"

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

new const block_text [][] =
{    
    
/*
        Words in here.
        Example:
    */
    
    
"swear""s-w-e-a-r""s.w.e.a.r"
}

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say""handle_say")
    
register_clcmd("say_team""handle_say")
}

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

public handle_say(id)
{
    new 
message[256]
    
read_args(messagecharsmax(message))
    
remove_quotes(message)    

    for(new 
0sizeof(block_text); i++)
        if(
containi(messageblock_text[i]) != -1)
            return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE
}

//////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////// 
Probably not the best method, buts its small and super easy.
Syturi0 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 07-23-2015 , 17:49   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #3

Also, its not cool going around PM'ing everyone to help your topic.

Last edited by Syturi0; 07-23-2015 at 17:50.
Syturi0 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-23-2015 , 17:50   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #4

write in .ini
PHP Code:
s.w.e.a.r
s
-w-e-a-
Depresie is offline
T0FF
Member
Join Date: Oct 2014
Location: Asia
Old 07-24-2015 , 06:20   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #5

Quote:
Originally Posted by Syturi0 View Post
PHP Code:
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

#include <amxmisc>

#pragma tabsize 0

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

new const     PLUGIN []        =    "Anti Chat",
                    
VERSION []    =    "1.0",
                    
AUTHOR []    =    "Syturio"

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

new const block_text [][] =
{    
    
/*
        Words in here.
        Example:
    */
    
    
"swear""s-w-e-a-r""s.w.e.a.r"
}

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say""handle_say")
    
register_clcmd("say_team""handle_say")
}

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

public handle_say(id)
{
    new 
message[256]
    
read_args(messagecharsmax(message))
    
remove_quotes(message)    

    for(new 
0sizeof(block_text); i++)
        if(
containi(messageblock_text[i]) != -1)
            return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE
}

//////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////// 
Probably not the best method, buts its small and super easy.
Thanks bro for response.
But can't it be coded inside the plugin i provided?
That plugin has also blacklist.config file which consists of swearing words.
So i just want that plugin to be edited to even block swearing words used with special characters.
T0FF is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 07-24-2015 , 06:51   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #6

Quote:
Originally Posted by Depresie View Post
write in .ini
PHP Code:
s.w.e.a.r
s
-w-e-a-
indraraj striker is offline
T0FF
Member
Join Date: Oct 2014
Location: Asia
Old 07-24-2015 , 11:59   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #7

Quote:
Originally Posted by Depresie View Post
write in .ini
PHP Code:
s.w.e.a.r
s
-w-e-a-
Problem, when space character is used.
T0FF is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 07-24-2015 , 12:25   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #8

Quote:
Originally Posted by T0FF View Post
Problem, when space character is used.
Just use my method. It does the same thing, and its better/simple.
Syturi0 is offline
T0FF
Member
Join Date: Oct 2014
Location: Asia
Old 07-24-2015 , 14:38   Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
Reply With Quote #9

Quote:
Originally Posted by Syturi0 View Post
Just use my method. It does the same thing, and its better/simple.
Yes buddy, its simple but my swearing word list is bit huge.
Would be more easier if you kindly make an swear.ini file of swearing words.
As well, kindly make a whitelist.ini file thou.
T0FF is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode