24/05/2020, 05:08 PM
(Última modificación: 24/05/2020, 05:20 PM por MatiasGFaria. Edited 1 time in total.)
Holaa estoy usando este anti Spam y me gustaria que tenga integrado el Chat Spam y Name Spam
Ejemplos
Chat Spam:
Pepe: Holaa
Pepe: Holaa
Pepe: Holaa
[Server] Tu CHAT todavia esta Bloqueado. Espera 3 minutos para que DESBLOQUEE.
Name Spam:
Pepe Cambio a Pepe1
Pepe1 Cambio a Jose
Jose Cambio a Pepe1
[Server] Tu Nombre todavia esta Bloqueado. Espera 3 minutos para que DESBLOQUEE.
Espero que me puedan ayudar
Ejemplos
Chat Spam:
Pepe: Holaa
Pepe: Holaa
Pepe: Holaa
[Server] Tu CHAT todavia esta Bloqueado. Espera 3 minutos para que DESBLOQUEE.
Name Spam:
Pepe Cambio a Pepe1
Pepe1 Cambio a Jose
Jose Cambio a Pepe1
[Server] Tu Nombre todavia esta Bloqueado. Espera 3 minutos para que DESBLOQUEE.
Espero que me puedan ayudar
Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <regex>
#define PATTERN "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" // \b
// Plugin Data
new const PLUGIN[] = "Anti-Spam"
new const VERSION[] = "v2.5.2"
new const AUTHOR[] = "Kane,ReymonARG,>>-T-E-R-M-I->>"
enum{
NUM = 0,
POINT = 1,
DPOINT = 2,
WWW = 3,
TOTAL_LTS
}
public client_putinserver(id)
check_user_name(id)
public client_infochanged(id)
{
new oldname[32], newname[32]
get_user_name(id, oldname, 31)
get_user_info(id, "name", newname, 31)
if( !equal(oldname, newname) )
check_user_name(id, newname)
}
stock check_user_name(id, const name[32] = "")
{
new plrname[32]
if(equal(name, ""))
{
get_user_name(id, plrname, 31)
}
else
{
plrname = name
}
new g_returnvalue, g_error[64]
new Regex:g_result = regex_match(plrname, PATTERN, g_returnvalue, g_error, 63)
switch(g_result)
{
case REGEX_MATCH_FAIL, REGEX_PATTERN_FAIL:
{
return log_amx("REGEX ERROR! %s", g_error)
}
case REGEX_NO_MATCH:
{
return 0
}
default:
{
new name[33]
get_user_name(id, name, 32)
client_cmd(id, "name ^"Intento Spammear^"")
client_print(0, print_chat, "[Server] %s Fue kickeado por ponerse una ip en el nombre", name)
server_cmd("kick %s", name)
return 1
}
}
return -1
}
public MessageNameChange(msgid, dest, id)
{
new szInfo[64]
get_msg_arg_string(2, szInfo, 63)
if(!equali(szInfo, "#Cstrike_Name_Change"))
{
return PLUGIN_CONTINUE
}
return PLUGIN_HANDLED
}
public hook_say(id)
{
new args[192], contador[TOTAL_LTS]
read_args(args, 191)
replace_all(args, 191, " ", "")
for( new i = 0; i < strlen(args) ; i++)
{
switch(args[i])
{
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' : contador[NUM]++
case '.' : contador[POINT]++
case ':' : contador[DPOINT]++
case 'w' : contador[WWW]++
}
}
if(contador[NUM] >= 5 && contador[POINT] || (contador[WWW] >= 3 && containi(args,".com")))
{
client_print(id, print_chat, "[Server] Mensaje bloqueado. Considerado Spam")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Prefix
new const szPrint[] = "^4[^3Server^4]^1 Anti-Spam detecto una^3"
// MsgIds
new msgSayText, g_count_spam[33]
// Regex
new Regex:g_rWeb, Regex:g_rIp, g_iRet
// Default Values
new g_iMaxSpams = 5, g_iSpamAdd = 1
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say_team", "hook_say")
register_clcmd("say", "hook_say")
register_message(get_user_msgid("SayText"), "MessageNameChange")
// Eventos
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
// Fakemeta
register_forward(FM_ClientUserInfoChanged, "FMClientUserInfoChanged")
// MsgIds
msgSayText = get_user_msgid("SayText")
// Regex
new error[50]
g_rIp = regex_compile("(.+(\s)?\d{1,3}(\.|-|;|:|,|\s+|[A-Za-z])){1,3}", g_iRet, error, charsmax(error), "i")
if (g_rIp < REGEX_OK)
log_amx("Error de Regex IP: %d | %s", g_iRet, error)
g_rWeb = regex_compile("(^^http(s)://*)*[a-zA-Z0-9\-\.]+(,|\.|>|<)+[A-Za-z]{2,3}", g_iRet, error, charsmax(error), "i")
if (g_rWeb < REGEX_OK)
log_amx("Error de Regex Web: %d | %s", g_iRet, error)
}
public plugin_natives()
{
register_native("as_check_string", "native_check_string")
register_native("as_add_user_count", "native_add_user_count")
register_native("as_get_spam_count", "native_get_spam_count")
register_native("as_set_spam_add", "native_set_spam_add")
register_native("as_set_max_spams", "native_set_max_spams")
}
public plugin_end()
{
regex_free(g_rIp)
regex_free(g_rWeb)
}
// as_check_string(const string[], spam[12])
public native_check_string(iPlugin, iParams)
{
new string[70], spam[12]
get_string(1, string, 69)
get_string(2, spam, 11)
if (!string[0] || CheckString(string, spam))
{
set_string(2, spam, 11)
return 1;
}
return 0;
}
// as_add_user_count(id, iCount = 1)
public native_add_user_count(iPlugin, iParams)
{
new id = get_param(1)
if (!is_user_connected(id))
{
log_amx("[Server] Invlid Id (%d)", id)
return false;
}
new iCount = get_param(2)
set_count_spam(id, iCount)
return true;
}
// as_get_spam_count(id)
public native_get_spam_count(iPlugin, iParams)
{
new id = get_param(1)
if (!is_user_connected(id))
{
log_amx("[Server] Invlid Id (%d)", id)
return -1;
}
return g_count_spam[id];
}
// as_set_spam_add(num)
public native_set_spam_add(iPlugin, iParams)
{
new num = get_param(1)
// Sin sentido
if (!num || num > g_iMaxSpams)
return false;
g_iSpamAdd = num
return true;
}
// as_set_max_spams(num)
public native_set_max_spams(iPlugin, iParams)
{
new num = get_param(1)
// Sin sentido
if (!num || num < g_iSpamAdd)
return false;
g_iMaxSpams = num
return true;
}
public event_round_start()
chatcolor(0, "", PLUGIN, VERSION, AUTHOR)
//public client_putinserver(id)
public client_connect(id)
{
new name[32], spam[12]
get_user_name(id, name, charsmax(name))
// Regex Check
if (CheckString(name, spam))
{
server_cmd("kick #%d ^"Tu nombre tiene una %s en ella^"", get_user_userid(id), spam)
return;
}
g_count_spam[id] = 0
}
public FMClientUserInfoChanged(id)
{
if (!is_user_connected(id)) return FMRES_IGNORED;
// Name vars
static new_name[32], old_name[32];
get_user_name(id, old_name, charsmax(old_name))
get_user_info(id, "name", new_name, charsmax(new_name))
// El mismo nombre..
if (equal(new_name, old_name))
return FMRES_IGNORED;
// Regex Check
new spam[12]
if (CheckString(new_name, spam))
{
set_count_spam(id, g_iSpamAdd)
set_user_info(id, "name", old_name)
chatcolor(id, "%s %s", szPrint, spam)
return FMRES_SUPERCEDE;
}
// Set new name
set_user_info(id, "name", new_name)
return FMRES_SUPERCEDE;
}
bool:CheckString(const string[], spam[12])
{
// Comparamos la string con nuestro pattern
if (regex_match_c(string, g_rIp, g_iRet))// || regex_match_c(string, g_rIp2, g_iRet))
{
formatex(spam, 3, "IP")
return true;
}
// Comparamos la string con nuestro pattern de nuevo
else if (regex_match_c(string, g_rWeb, g_iRet))
{
formatex(spam, 11, "Pagina Web")
return true;
}
return false;
}
set_count_spam(id, iCount)
{
if (g_count_spam[id] + iCount >= g_iMaxSpams)
{
server_cmd("kick #%d ^"Intentos multiples de Spam.^"", get_user_userid(id))
return;
}
g_count_spam[id] += iCount
chatcolor(id, "^4[^3Server^4]^1 ^1Te quedan ^3%d ^1/ ^3%d ^1para no ser kickeado por ^4Spammer", g_count_spam[id], g_iMaxSpams)
}
stock chatcolor(id, const input[], any:...)
{
static szMsg[191]
vformat(szMsg, 190, input, 3)
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgSayText, .player = id)
write_byte(id ? id : 33)
write_string(szMsg)
message_end()
}