Code:
/* AMX Mod script.
*
* (c) Copyright 2003, Dra
* This file is provided as is (no warranties).
*
* set sewar words in "wordlist.txt" at amx directory (default :
addons/amx/)
*/
#include <amxmod>
#include <amxmisc>
#define MAX_WORD_NUM 70
/* cvar : amx_maxswear 3 , one map swear 3 times punish it */
new SwearSlap = 50 /* every swear slap damage */
new SwearMoney = 1000 /* every swear lost money */
new SwearType = 3 /* punish type : 1 kick, 2 ban, 3 gag, 0 do
nothing */
new SwearBanTime = 5 /* ban punish time */
new ReplaceType = 1 /* swear msg : 1 replace swear words to '*', 2
handle msg, 3 replace msg */
new PrintMode = 0 /* 0 User's Command, 1 ServerSay, 2 Tsay */
new replacemsg1[] = "%s tried to swear%s"
new replacemsg2[] = ", but if %s do it %d more times %s will be %sed!"
tsay_init() set_hudmessage(220, 220, 220, 0.05, 0.7, 0, 1.0, 10.0)
new wordfile[] = "$basedir/wordlist.txt"
new words[MAX_WORD_NUM][32]
new wlen[MAX_WORD_NUM]
new wnum
new swearflag[33]
new g_logFile[16]
new spword[4][] = {"","kick","bann","gag"}
public handlesay(id,level,cid) {
new msg[192]
new i, b, j, s, len
if (swearflag[id]==-1) {
client_print(id,print_notify,"* You are gagged...")
return PLUGIN_HANDLED
}
read_args(msg,191)
for (i=0;i<wnum;++i)
if ((b=containi(msg,words[i]))!=-1) {
s = 1
for (j=b;j<b+wlen[i];++j)
msg[j]='*'
}
if (!s) return PLUGIN_CONTINUE
b = get_cvar_num("amx_maxswear")
if (++swearflag[id]>= b) {
if (SwearType && run_punish(id)!=3) return PLUGIN_HANDLED
}
set_user_money(id,max(get_user_money(id)-SwearMoney,0))
if (is_user_alive(id))
user_slap(id,min(get_user_health(id)-1,SwearSlap))
if (swearflag[id]==-1 || ReplaceType==2) return PLUGIN_HANDLED
if (!ReplaceType) return PLUGIN_CONTINUE
new name[32]
get_user_name(id,name,31)
if (ReplaceType==3) {
new sa[32], sb[4]
if (PrintMode) {
copy(sa,31,name)
copy(sb,3,"he")
} else {
copy(sa,31,"I")
copy(sb,3,"I")
}
len = format(msg,191,replacemsg1, sa , swearflag[id] == 1 ? "" :
" once again")
if (SwearType)
format(msg[len],191-len,replacemsg2, sb, b-swearflag[id], sb,
spword[SwearType])
} else if (PrintMode) {
format(msg,191,"%s : %s", name, msg)
}
switch (PrintMode) {
case 0 : {
new cmd[32]
read_argv(0,cmd,31)
client_cmd(id,"%s %s",cmd,msg)
}
case 2 : {
tsay_init()
show_hudmessage(0,msg)
}
default : client_print(0,print_chat,msg)
}
return PLUGIN_HANDLED
}
public run_punish(id) {
new name[32], bantag[32]
get_user_name(id,name,31)
console_print(0,"[swear] %s have been %sed
.",name,spword[SwearType])
if (SwearType==2) {
console_print(id,"* you have been banned %d due to swear punish
.",SwearBanTime)
if (get_cvar_num("sv_lan")){
get_user_ip(id, bantag, 31,1)
server_cmd("addip %i %s;wait;writeip;kick #%d", SwearBanTime,
bantag, get_user_userid(id))
} else {
get_user_authid(id, bantag, 31)
server_cmd("banid %i %s kick;wait;writeid",SwearBanTime
,bantag)
}
log_to_file(g_logFile,"(swear) banned %d %s <%s> due to swear
punish",SwearBanTime, name,bantag)
return 2
}
if (SwearType==1) {
log_to_file(g_logFile,"(swear) kicked %s <%s> due to swear
punish", name,bantag)
console_print(id,"* you have been kicked due to swear punish .")
server_cmd("kick #%d", get_user_userid(id) )
return 1
}
swearflag[id] = -1
client_print(id,print_notify,"* You are gagged...")
return 3
}
public read_wordfile() {
new line, filename[64]
build_path(filename,63,wordfile)
if (!file_exists(filename)) return 0
while (wnum<MAX_WORD_NUM &&
read_file(filename,line++,words[wnum],31,wlen[wnum]))
if (words[wnum][0] != ';') wnum++
return wnum
}
public client_connect(id)
swearflag[id]=0
public plugin_init() {
register_plugin("Amx Max Swear","0.9.3","dra")
register_clcmd("say","handlesay")
register_clcmd("say_team","handlesay")
register_clcmd("amx_say","handlesay")
register_clcmd("amx_chat","handlesay")
register_clcmd("amx_psay","handlesay")
register_clcmd("amx_tsay","handlesay")
register_clcmd("amx_vote","handlesay")
register_cvar("amx_maxswear","3")
if (SwearType<0 || SwearType>3) SwearType=1
get_logfile(g_logFile,15)
read_wordfile()
return PLUGIN_CONTINUE
}