Код:
#include <amxmodx>
#include <amxmisc>
#define NAME "AntiMat"
#define VERSION "1.0"
#define AUTHOR "Crash94"
stock const ReplaceText[256][128]
new Msg[512], szText[ 555 char ]
new warning_chat[33]
new g_Warning, g_Punishment, g_Bantime
public plugin_init()
{
register_plugin(NAME, VERSION, AUTHOR)
register_clcmd("say", "CheckSay")
register_clcmd("say_team", "CheckSayTeam")
g_Warning = register_cvar("amx_antimat_warning", "3")
g_Punishment = register_cvar("amx_antimat_punishment", "0")
g_Bantime = register_cvar("amx_antimat_bantime", "1")
register_dictionary( "antimat.txt" );
set_task(1.0, "loadfile")
}
public client_disconnect(id)
{
warning_chat[id] = 0
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!team", "^3")
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
public loadfile()
{
new config[64]
get_configsdir(config, 64)
format(config, 63, "%s/antimat.ini", config)
new line = 0
new textsize = 0
new text[128]
new temp[128]
new i = 0
if (file_exists(config))
{
while(read_file(config,line,text,255,textsize))
{
format(temp,127,"%s",text)
ReplaceText[i++]=temp
line++
}
}
}
public CheckSay(id)
{
if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
{
return PLUGIN_CONTINUE;
}
new message[192],Len
new szName[32], i
new iPlayer[32], iNum
read_args(message, 191);
remove_quotes(message);
get_players(iPlayer, iNum)
get_user_name(id,szName,31);
for(i = 0 ; i < sizeof (ReplaceText) ; i++)
{
if(containi(message, ReplaceText[i]) != -1)
{
++warning_chat[id]
if(is_user_alive(id))
{
Len = format(Msg[Len], charsmax(Msg) - 1, "");
Len += format(Msg[Len], charsmax(Msg) - 1, "!team%s !y: ",szName);
Len += format(Msg[Len], charsmax(Msg) - 1, "%s",message);
formatex( szText, charsmax( szText ), "!g%L!y", id, "ANTIMAT_REPLACE_TEXT");
replace_all(Msg, charsmax(Msg), ReplaceText[i], szText)
for(new i; i < iNum; i++)
{
if (is_user_connected(iPlayer[i]) && is_user_alive(iPlayer[i]))
{
ChatColor(iPlayer[i], Msg)
}
}
check_warning(id)
}else{
Len = format(Msg[Len], charsmax(Msg) - 1, "!y *DEAD* ");
Len += format(Msg[Len], charsmax(Msg) - 1, "!team%s !y: ",szName);
Len += format(Msg[Len], charsmax(Msg) - 1, "%s",message);
formatex( szText, charsmax( szText ), "!g%L!y", id, "ANTIMAT_REPLACE_TEXT");
replace_all(Msg, charsmax(Msg), ReplaceText[i], szText)
for(new i; i < iNum; i++)
{
if (is_user_connected(iPlayer[i]) && !is_user_alive(iPlayer[i]))
{
ChatColor(iPlayer[i], Msg)
}
}
check_warning(id)
}
return PLUGIN_HANDLED_MAIN
}
}
return PLUGIN_CONTINUE;
}
public CheckSayTeam(id)
{
if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
{
return PLUGIN_CONTINUE;
}
new message[192],Len
new szName[32], i, j
new iPlayer[32], iNum
read_args(message, 191);
remove_quotes(message);
get_players(iPlayer, iNum)
get_user_name(id,szName,31);
for(i = 0 ; i < sizeof (ReplaceText) ; i++)
{
if(containi(message, ReplaceText[i]) != -1)
{
++warning_chat[id]
if(is_user_alive(id))
{
if(get_user_team(id)==1)
{
Len = format(Msg[Len], charsmax(Msg) - 1, "!y(Terrorist)");
}else{
Len = format(Msg[Len], charsmax(Msg) - 1, "!y(Counter-Terrorist)");
}
Len += format(Msg[Len], charsmax(Msg) - 1, "!team%s !y: ",szName);
Len += format(Msg[Len], charsmax(Msg) - 1, "%s",message);
formatex( szText, charsmax( szText ), "!g%L!y", id, "ANTIMAT_REPLACE_TEXT");
replace_all(Msg, charsmax(Msg), ReplaceText[i][j], szText)
for(new i; i < iNum; i++)
{
if (is_user_connected(iPlayer[i]) && is_user_alive(iPlayer[i]))
{
ChatColor(iPlayer[i], Msg)
}
}
check_warning(id)
}else{
if(get_user_team(id)==1)
{
Len = format(Msg[Len], charsmax(Msg) - 1, "!y*DEAD*(Terrorist)");
}else{
Len = format(Msg[Len], charsmax(Msg) - 1, "!y*DEAD*(Counter-Terrorist)");
}
Len += format(Msg[Len], charsmax(Msg) - 1, "!team%s !y: ",szName);
Len += format(Msg[Len], charsmax(Msg) - 1, "%s",message);
formatex( szText, charsmax( szText ), "!g%L!y", id, "ANTIMAT_REPLACE_TEXT");
replace_all(Msg, charsmax(Msg), ReplaceText[i][j], szText)
for(new i; i < iNum; i++)
{
if (is_user_connected(iPlayer[i]) && !is_user_alive(iPlayer[i]))
{
ChatColor(iPlayer[i], Msg)
}
}
check_warning(id)
}
return PLUGIN_HANDLED_MAIN
}
}
return PLUGIN_CONTINUE;
}
public check_warning(id)
{
if(warning_chat[id]>=get_pcvar_num(g_Warning))
{
switch(get_pcvar_num(g_Punishment))
{
case 0:
{
new name[32]
get_user_name(id, name, 31)
server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "ANTIMAT_REASON_KICK")
ChatColor(0, "%L",0,"ANTIMAT_KICKPLAYER", name)
}
case 1:
{
new ip[32], name[32]
get_user_ip(id, ip, 31, 1)
get_user_name(id, name, 31)
server_cmd("addip %d %s; writeip", get_pcvar_num(g_Bantime), ip)
ChatColor(0, "%L",0,"ANTIMAT_BANPLAYER", name, get_pcvar_num(g_Bantime))
}
default:
{
new name[32]
get_user_name(id, name, 31)
server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "ANTIMAT_REASON_KICK")
ChatColor(0, "%L",0,"ANTIMAT_KICKPLAYER", name)
}
}
}else{
ChatColor(id, "%L",0,"ANTIMAT_WARNING_INFO")
ChatColor(id, "%L",0,"ANTIMAT_WARNING_INFO1", warning_chat[id], get_pcvar_num(g_Warning))
}
}