PHP- Kodu:
#include <amxmodx>
#include <amxmisc>
#include <string>
#define PLUGIN "NoAds"
#define VERSION "0.5"
#define AUTHOR "AdaskoMX"
stock const advertising_words[][] = {
"https://",
"www.",
".com",
".net",
".org",
".ru",
".pl",
".de",
".co.uk",
".info"
}
stock const advertising_allowed[][] = {
"zal."
}
new adshost, adsip;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say", "hook_chat");
register_clcmd("say_team", "hook_chat");
//register_cvar("amx_adspunish_mode","1")
//register_cvar("amx_adsban_time","5")
adshost = register_cvar("amx_adsaddress", "")
adsip = register_cvar("amx_adsip", "")
}
public hook_chat(id)
{
new temp[512], szArgs[512], said[512], adres[60], adresIP[40]
read_args(szArgs, 511)
get_pcvar_string(adshost, adres, 60)
get_pcvar_string(adsip, adresIP, 40)
new len = strlen(szArgs)
new digits, periods, pos, start, stop, i, j
new szName[32]
get_user_name(id, szName, 31)
new bool:allow, bool:ip, bool:sprawdz;
if(len >= 2 && szArgs[0] == '"' && szArgs[len - 1] == '"'){
len -= 2;
copy(szArgs, len, szArgs[1]);
}
temp = szArgs;
said = szArgs;
for(i = 0 ; i < sizeof (advertising_words) ; i++){
stop = 0;
while((pos = containi(szArgs[stop], advertising_words[i])) != -1){
pos += stop;
start = pos; while(start > 0 && szArgs[start - 1] != ' ') start --
stop = pos; while(stop < len && szArgs[stop] != ' ') stop ++
allow = false;
for(j = 0 ; j < sizeof (advertising_allowed) ; j ++){
periods = containi(szArgs[start], advertising_allowed[j]);
if(periods < stop - start && periods >= 0){
allow = true;
}
}
if(!allow){
copy(said, start, szArgs)
strcat(said, adres, 512)
strcat(said, szArgs[stop], 512)
szArgs = said;
len = strlen(szArgs);
stop = start + strlen(adres);
}
}
}
for(i = 0 ; i < len; i++)
{
sprawdz = false;
if(isdigit(szArgs[i]))
{
if(digits == 0) start = i;
digits++;
if(periods > 2 && digits > 3){
ip = true;
pos = start;
}
}
else if(szArgs[i] == '.' || szArgs[i] == ':')
{
periods++
}
else if(szArgs[i] == ' ')
{
periods = 0;
digits = 0;
} else sprawdz = true;
if((sprawdz || i == len - 1) && ip){
ip = false;
start = pos; while(start > 0 && szArgs[start - 1] != ' ') start --
stop = pos; while(stop < len && szArgs[stop] != ' ') stop ++
copy(said, start, szArgs)
strcat(said, adresIP, 512)
strcat(said, szArgs[stop], 512)
szArgs = said;
len = strlen(szArgs);
}
}
if(!equal(said, temp)){
new cmd[10]
read_argv ( 0, cmd, 9)
format(said, 512, "^"%s^"", said);
engclient_cmd ( id ,cmd , said )
return 1;
}
return 0;
}