Post by KillerMen on Jun 19, 2016 19:38:31 GMT
Hello !
I'm Going To Post Plugin : Anti Pub
You Can't say IP Server in Say
Sma & Amxx
I'm Going To Post Plugin : Anti Pub
You Can't say IP Server in Say
Sma & Amxx
#include <amxmodx>
#include <amxmisc>
#include <geoip>
#include <colorchat>
#define SIZE 32
#define MAX_PLAYERS 32
enum { CHECK_NO, CHECK_FIRST, CHECK_CHANGE }
new pCvar_MaxDigits
new pCvar_Prefix[SIZE]
new pCvar_Status
new szMessage[ 194 ]
new g_iCheckStatus[ MAX_PLAYERS + 1 ]
new const g_szNameKey[ ] = "name"
public plugin_init( )
{
register_plugin( "Anti PuB", "3.0", "KilLeR MeN =)")
register_cvar("antireklama", "3.0" , (FCVAR_SERVER|FCVAR_SPONLY))
register_srvcmd("antireklama_prefix", "prefix")
register_clcmd( "say", "CmdSay" )
register_clcmd( "say_team", "CmdSay" )
pCvar_Status = register_cvar("antireklama_status", "1", ADMIN_RCON)
pCvar_MaxDigits = register_cvar( "antireklama_maxbrojeva", "12", ADMIN_RCON)
}
public prefix()
{
remove_task(123)
read_argv(1, pCvar_Prefix, SIZE-1)
}
public CmdSay( id )
{
if(get_pcvar_num(pCvar_Status) == 1)
{
read_args( szMessage, charsmax( szMessage ) )
remove_quotes( szMessage )
new iCount
new iMax = get_pcvar_num( pCvar_MaxDigits )
new i = -1
while( szMessage[ ++i ] )
{
if( '0' <= szMessage[ i ] <= '9' )
{
if( ++iCount >= iMax )
{
AntiReklamaLog( id, szMessage )
return PLUGIN_HANDLED
}
}
}
}
return PLUGIN_CONTINUE
}
public client_putinserver( id )
{
if(get_pcvar_num(pCvar_Status) == 1)
{
g_iCheckStatus[ id ] = CHECK_FIRST
new szName[ 32 ], text[512]
get_user_name( id, szName, charsmax( szName ) )
if( !IsNameValid( szName ) )
{
AntiReklamaLog( id, "Reklama je bila u imenu..." )
format(text,511,"%s Anti Reklama", pCvar_Prefix)
set_user_info( id, g_szNameKey, text)
//AntiReklamaPunish( id )
}
g_iCheckStatus[ id ] = CHECK_CHANGE
}
}
public client_disconnect( id )
g_iCheckStatus[ id ] = CHECK_NO
public client_infochanged( id )
{
if(get_pcvar_num(pCvar_Status) == 1)
{
if( g_iCheckStatus[ id ] == CHECK_CHANGE )
{
new newname[32],oldname[32], text[512]
get_user_info(id, "name", newname,31)
get_user_name(id, oldname,31)
if( !equal( newname, oldname) && !IsNameValid(newname ) )
{
AntiReklamaLog( id, "Reklama je bila u imenu..." )
format(text,511,"%s Anti Reklama", pCvar_Prefix)
set_user_info( id, g_szNameKey, text)
}
}
}
}
bool:IsNameValid( const szName[ ] )
{
new iCount
new iMax = get_pcvar_num( pCvar_MaxDigits )
new i = -1
while( szName[ ++i ] )
{
if( '0' <= szName[ i ] <= '9' )
{
if( ++iCount >= iMax )
{
return false
}
}
}
return true
}
public AntiReklamaLog( id, szMessage[] )
{
new szName[ 32 ], szAuthID[ 32 ], szUserIP[ 32 ], szCountry[ 32 ]
get_user_name( id, szName, 31 )
get_user_authid( id, szAuthID, 31 )
get_user_ip( id, szUserIP, 31, 1 )
geoip_country( szUserIP, szCountry )
static szLogData[ 200 ]
formatex( szLogData, sizeof szLogData - 1, "Nick: %s | ID: %s | IP: %s | Earth: %s | %s", szName, szAuthID, szUserIP, szCountry, szMessage)
log_to_file( "antireklama.log", szLogData )
console_print( id, szLogData )
return PLUGIN_HANDLED
}