Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
|
07-23-2015
, 17:48
Re: Add Filter Special Characters (!#$%*) Functionality In This Plugin
|
#2
|
Quote:
Originally Posted by T0FF
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(PLUGIN, VERSION, AUTHOR)
register_clcmd("say", "handle_say")
register_clcmd("say_team", "handle_say")
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
public handle_say(id)
{
new message[256]
read_args(message, charsmax(message))
remove_quotes(message)
for(new i = 0; i < sizeof(block_text); i++)
if(containi(message, block_text[i]) != -1)
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
Probably not the best method, buts its small and super easy.
|
|