Code: Select all
#include <amxmodx>
#include <amxmisc>
#include <nfvault>
new g_szVaultFile[ 128 ];
new g_szAuthID[ 33 ][ 25 ];
new g_iWarningsCount[ 33 ];
new g_iInfractionsCount[ 33 ];
new g_iCvarBanTime;
new g_iCvarBanMethod;
new g_iCvarMaxWarnings;
new g_iCvarMaxInfractions;
new g_iCacheCvarBanTime;
new g_iCacheCvarBanMethod;
new g_iCacheCvarMaxWarnings;
new g_iCacheCvarMaxInfractions;
public plugin_init( )
{
register_plugin( "[ZP] warn infractiuni", "0.1.5", "DruX" );
register_concmd( "amx_warn", "ConCmd_Warning", ADMIN_CVAR, "<nume sau #userid> <motiv> - Adauga un warn unui jucator." );
register_concmd( "amx_infractiuni", "ConCmd_Infraction", ADMIN_CVAR, "<nume sau #userid> <motiv> - Adauga o infractiune unui jucator." );
register_concmd( "amx_scoatewarn", "ConCmd_WarningRemove", ADMIN_CVAR, "<nume sau #userid> - Elimina un warn unui jucator." );
register_concmd( "amx_scoateinfractiuni", "ConCmd_InfractionRemove", ADMIN_CVAR, "<nume sau #userid> - Elimina o infractiune unui jucător." );
g_iCvarBanTime = register_cvar( "amx_infractions_bantime", "60" );
g_iCvarBanMethod = register_cvar( "amx_infractions_banmethod", "1" );
g_iCvarMaxWarnings = register_cvar( "amx_warnings_max", "3" );
g_iCvarMaxInfractions = register_cvar( "amx_infractions_max", "3" );
register_clcmd( "say /warn", "ClCmd_Warnings", ADMIN_KICK, "- Verifica warn-urile tale curente" );
register_clcmd( "say /infractiuni", "ClCmd_Infractions", ADMIN_KICK, "- Verifica infractiunile tale curente" );
register_event( "HLTV", "Event_HLTV_RoundStart", "a", "1=0", "2=0" );
nfv_file( "zp_infractiuni_warn.txt", g_szVaultFile, charsmax( g_szVaultFile ) );
register_dictionary( "zp_warn_infractiuni.txt" );
}
public plugin_cfg( )
{
Event_HLTV_RoundStart( );
}
public client_authorized( id )
{
get_user_authid( id, g_szAuthID[ id ], charsmax( g_szAuthID[ ] ) );
}
public client_putinserver( id )
{
if ( !is_user_hltv( id ) && !is_user_bot( id ) )
{
g_iWarningsCount[ id ] = nfv_get_num( g_szVaultFile, g_szAuthID[ id ], "warnings" );
g_iInfractionsCount[ id ] = nfv_get_num( g_szVaultFile, g_szAuthID[ id ], "infractions" );
}
}
public client_disconnect( id )
{
nfv_set_num( g_szVaultFile, g_szAuthID[ id ], "warnings", g_iWarningsCount[ id ] );
nfv_set_num( g_szVaultFile, g_szAuthID[ id ], "infractions", g_iInfractionsCount[ id ] );
}
public ConCmd_Warning( id, iLevel, iCid )
{
if ( cmd_access( id, iLevel, iCid, 3 ) )
{
new szTarget[ 32 ];
read_argv( 1, szTarget, charsmax( szTarget ) );
new szReason[ 32 ];
read_argv( 2, szReason, charsmax( szReason ) );
new iPlayer = cmd_target( id, szTarget, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS );
if ( iPlayer )
{
if ( ++g_iWarningsCount[ iPlayer ] >= g_iCacheCvarMaxWarnings )
{
if ( ++g_iInfractionsCount[ iPlayer ] >= g_iCacheCvarMaxInfractions )
{
g_iWarningsCount[ iPlayer ] = 0;
g_iInfractionsCount[ iPlayer ] = 0;
new iUserID = get_user_userid( iPlayer );
switch ( g_iCacheCvarBanMethod )
{
case 0:
{
server_cmd( "kick #%d ^"%L^";wait;banid ^"%s^" ^"%s^";wait;writeid", iUserID, iPlayer, "KICK_MESSAGE", g_iCacheCvarBanTime, g_szAuthID[ iPlayer ] );
}
case 1:
{
server_cmd( "amx_ban ^"#%d^" ^"%d^" ^"%L^"", iUserID, g_iCacheCvarBanTime, iPlayer, "KICK_MESSAGE" );
}
case 2:
{
server_cmd( "amx_ban ^"%d^" ^"#%d^" ^"%L^"", g_iCacheCvarBanTime, iUserID, iPlayer, "KICK_MESSAGE" );
}
}
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG2", g_szAuthID[ iPlayer ] );
}
else
{
g_iWarningsCount[ iPlayer ] = 0;
print_color( iPlayer, "!g[!vAMXX!g] %L", iPlayer, "WARNINGS_REACHED", g_iCacheCvarMaxWarnings );
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG1", g_szAuthID[ iPlayer ] );
}
}
else
{
print_color( iPlayer, "!g[!vAMXX!g] %L", iPlayer, "WARNING_MESSAGE", szReason );
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG3", g_szAuthID[ iPlayer ], g_szAuthID[ id ], szReason );
}
}
}
return PLUGIN_HANDLED;
}
public ConCmd_Infraction( id, iLevel, iCid )
{
if ( cmd_access( id, iLevel, iCid, 3 ) )
{
new szTarget[ 32 ];
read_argv( 1, szTarget, charsmax( szTarget ) );
new szReason[ 32 ];
read_argv( 2, szReason, charsmax( szReason ) );
new iPlayer = cmd_target( id, szTarget, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS );
if ( iPlayer )
{
if ( ++g_iInfractionsCount[ iPlayer ] >= g_iCacheCvarMaxInfractions )
{
g_iWarningsCount[ iPlayer ] = 0;
g_iInfractionsCount[ iPlayer ] = 0;
new iUserID = get_user_userid( iPlayer );
switch ( g_iCacheCvarBanMethod )
{
case 0:
{
server_cmd( "kick #%d ^"%L^";wait;banid ^"%s^" ^"%s^";wait;writeid", iUserID, iPlayer, "KICK_MESSAGE", g_iCacheCvarBanTime, g_szAuthID[ iPlayer ] );
}
case 1:
{
server_cmd( "amx_ban ^"#%d^" ^"%d^" ^"%L^"", iUserID, g_iCacheCvarBanTime, iPlayer, "KICK_MESSAGE" );
}
case 2:
{
server_cmd( "amx_ban ^"%d^" ^"#%d^" ^"%L^"", g_iCacheCvarBanTime, iUserID, iPlayer, "KICK_MESSAGE" );
}
}
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG2", g_szAuthID[ iPlayer ] );
}
else
{
print_color( iPlayer, "!g[!vAMXX!g] %L", iPlayer, "INFRACTION_MESSAGE", szReason );
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG4", g_szAuthID[ iPlayer ], g_szAuthID[ id ], szReason );
}
}
}
return PLUGIN_HANDLED;
}
public ConCmd_WarningRemove( id, iLevel, iCid )
{
if ( cmd_access( id, iLevel, iCid, 2 ) )
{
new szTarget[ 32 ];
read_argv( 1, szTarget, charsmax( szTarget ) );
new iPlayer = cmd_target( id, szTarget, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS );
if ( iPlayer )
{
if ( g_iWarningsCount[ iPlayer ] )
{
g_iWarningsCount[ iPlayer ]--;
print_color( iPlayer, "!g[!vAMXX!g] %L", iPlayer, "WARNING_REMOVED" );
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG5", g_szAuthID[ id ], g_szAuthID[ iPlayer ] );
}
else
{
print_color( id, "!g[!vAMXX!g] %L", id, "TARGET_ERROR1" );
}
}
}
return PLUGIN_HANDLED;
}
public ConCmd_InfractionRemove( id, iLevel, iCid )
{
if ( cmd_access( id, iLevel, iCid, 2 ) )
{
new szTarget[ 32 ];
read_argv( 1, szTarget, charsmax( szTarget ) );
new iPlayer = cmd_target( id, szTarget, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS );
if ( iPlayer )
{
if ( g_iInfractionsCount[ iPlayer ] )
{
g_iInfractionsCount[ iPlayer ]--;
print_color( iPlayer, "[!vAMXX!g] %L", iPlayer, "INFRACTION_REMOVED" );
log_amx( "%L", LANG_SERVER, "SYSTEM_LOG6", g_szAuthID[ id ], g_szAuthID[ iPlayer ] );
}
else
{
print_color( id, "!g[!vAMXX!g] %L", id, "TARGET_ERROR2" );
}
}
}
return PLUGIN_HANDLED;
}
public ClCmd_Warnings( id )
{
if (!(get_user_flags(id) & ADMIN_KICK))
{
print_color(id, "!g[!vAMXX!g] !vNu ai acces la comanda!!")
return PLUGIN_HANDLED;
}
else
{
print_color( id, "!g[!vAMXX!g] %L", id, "WARNING_COUNT", g_iWarningsCount[ id ] );
}
return PLUGIN_HANDLED;
}
public ClCmd_Infractions( id )
{
if (!(get_user_flags(id) & ADMIN_KICK))
{
print_color(id, "!g[!vAMXX!g] !vNu ai acces la comanda!!")
return PLUGIN_HANDLED;
}
else
{
print_color( id, "!g[!vAMXX!g] %L", id, "INFRACTION_COUNT", g_iInfractionsCount[ id ] );
}
return PLUGIN_HANDLED;
}
public Event_HLTV_RoundStart( )
{
g_iCacheCvarBanTime = get_pcvar_num( g_iCvarBanTime );
g_iCacheCvarBanMethod = get_pcvar_num( g_iCvarBanMethod );
g_iCacheCvarMaxWarnings = get_pcvar_num( g_iCvarMaxWarnings );
g_iCacheCvarMaxInfractions = get_pcvar_num( g_iCvarMaxInfractions );
}
stock print_color(const id, const input[ ], any:...)
{
new count = 1, players[32]
static msg[ 191 ]
vformat(msg, 190, input, 3)
replace_all( msg, 190, "!v", "^4" ) //- verde
replace_all( msg, 190, "!g", "^1" ) //- galben
replace_all( msg, 190, "!e", "^3" ) //- echipa
replace_all( msg, 190, "!n", "^0" ) //- normal
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( );
}
}
}
}