Код за потвърждение: Избери целия код
/* Plugin generated by AMXX-Studio */
#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
}