- SMA | Afiseaza codul
/* amx_autogag_time 3 // minutele pentru gag cand ia autogag amx_gag_minute_limit 300 // limita maxima pentru gag minute amx_gag_minute_in_seconds 60 // minute in secunde amx_gag_tagname 1 // pune taguri la gag amx_admingag 0 // poti da si la admini gag daca e egal cu 1, daca e 0 nu poti amx_maxwords 200 // lista maxima de cuvinte in gag_words.ini amx_gagtag * // tag-ul din chat amx_gag < nume > < timp in minute > - dai gag unui jucator pentru x minute amx_ungag < nume > ii scoti gag-ul unui jucator Cand un jucator cu gag iese de pe server va fi salvat intr-un fisier Atunci cand se va conecta pe server va avea gag exact cate minute mai avea cand a iesit de pe server Autor: Cristi. C */ #include < amxmodx > #include < amxmisc > #include < fakemeta > #include < engine > #include < nvault > #pragma semicolon 1 #define PLUGIN "Special Admin Gag" #define VERSION "1.0" #define COMMAND_ACCESS ADMIN_KICK // accesu adminilor pentru comanda #define MAX_PLAYERS 32 + 1 enum { INFO_NAME, INFO_IP, INFO_AUTHID }; new const gGagTag[ ] = "Gag#"; new const gGagFileName[ ] = "gag_words.ini"; new const gGagThinkerClassname[ ] = "GagThinker_"; new const gGagVaultName[ ] = "GaggedPlayers"; new PlayerGagged[ MAX_PLAYERS ]; new PlayerGagTime[ MAX_PLAYERS ]; new JoinTime[ MAX_PLAYERS ]; new szName[ 33 ]; new g_Words[ 562 ] [ 32 ], g_Count; new szOldName[ MAX_PLAYERS ] [ 40 ]; new gCvarSwearGagTime; new gCvarGagMinuteLimit; new gCvarGagMinuteInSeconds; new gCvarAdminGag; new gCvarTagName; new gCvarWords; new gCvarTag; new gMaxPlayers; new gVault; public plugin_init( ) { register_plugin( PLUGIN, PLUGIN, "Cristi .C" ); register_concmd( "amx_gag", "CommandGag" ); register_concmd( "amx_ungag", "CommandUngag" ); register_clcmd( "say", "CheckGag" ); register_clcmd( "say_team", "CheckGag" ); GagThinker( ); register_think( gGagThinkerClassname, "Forward_GagThinker" ); gCvarSwearGagTime = register_cvar( "amx_autogag_time", "3" ); // minutele pentru gag cand ia autogag gCvarGagMinuteLimit = register_cvar( "amx_gag_minute_limit", "300" ); // limita maxima pentru gag minute gCvarGagMinuteInSeconds = register_cvar( "amx_gag_minute_in_seconds", "60" ); // minute in secunde gCvarTagName = register_cvar( "amx_gag_tagname", "1" ); // pune taguri la gag gCvarAdminGag = register_cvar( "amx_admingag", "0" ); // poti da si la admini gag daca e egal cu 1, daca e 0 nu poti gCvarWords = register_cvar( "amx_maxwords", "200" ); // lista maxima de cuvinte in gag_words.ini gCvarTag = register_cvar( "amx_gagtag", "*" ); // tag-ul din chat gMaxPlayers = get_maxplayers( ); gVault = nvault_open( gGagVaultName ); if( gVault == INVALID_HANDLE ) { set_fail_state( "nValut returned invalid handle!" ); } } public plugin_cfg( ) { static szConfigDir[ 64 ], iFile[ 64 ]; get_localinfo ( "amxx_configsdir", szConfigDir, 63 ); formatex ( iFile , charsmax( iFile ) , "%s/%s" , szConfigDir, gGagFileName ); if( !file_exists( iFile ) ) { write_file( iFile, "# Pune aici cuvintele jignitoare sau reclamele", -1 ); } new szBuffer[ 128 ]; new szFile = fopen( iFile, "rt" ); while( !feof( szFile ) ) { fgets( szFile, szBuffer, charsmax( szBuffer ) ); if( szBuffer[ 0 ] == '#' ) { continue; } parse( szBuffer, g_Words[ g_Count ], sizeof g_Words[ ] - 1 ); g_Count++; if( g_Count >= get_pcvar_num ( gCvarWords ) ) { break; } } fclose( szFile ); } public client_putinserver( id ) { if ( is_user_connected( id ) ) { JoinTime[ id ] = get_systime( ); } } public client_disconnect( id ) { if ( PlayerGagged[ id ] == 1 ) { client_print( id, print_chat, "%s Jucatorul cu gag %s(%s|%s), s-a deconectat!", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ), GetInfo( id, INFO_AUTHID ) ); } JoinTime[ id ] = 0 ; SaveGag( id ); } public client_connect( id ) { LoadGag( id ); } public CheckGag( id ) { new szSaid[ 192 ]; read_args( szSaid, charsmax( szSaid ) ); remove_quotes( szSaid ); if( !UTIL_IsValidMessage( szSaid ) ) { return 1; } if ( PlayerGagged[ id ] == 1 ) { PlayerGagged[ id ] = 1; client_print( id, print_chat, "%s Ai primit Gag pentru limbaj vulgar, asteapta %d minute!", get_tag( ), PlayerGagTime[ id ] ); return 1; } else { new i; for( i = 0; i < get_pcvar_num ( gCvarWords ); i++ ) { if( containi( szSaid, g_Words[ i ] ) != -1 ) { if( get_pcvar_num( gCvarAdminGag ) == 0 ) { if ( is_user_admin ( id ) ) { return 1; } } get_user_name( id, szName, sizeof ( szName ) -1 ); if ( get_pcvar_num( gCvarTagName ) == 1 ) { client_cmd( id, "name ^"%s %s^"", gGagTag, szName ); } szOldName[ id ] = szName; PlayerGagged[ id ] = 1; PlayerGagTime[ id ] = get_pcvar_num ( gCvarSwearGagTime ); set_speak( id, SPEAK_MUTED ); client_print( 0, print_chat, "%s %s (%s) a primit AutoGag pentru limbaj sau reclama!", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ) ); client_print( id, print_chat, "%s Ai primit AutoGag pentru injuratura sau reclama! Timpul expira in: %d minute!", get_tag( ), PlayerGagTime[ id ] ); client_print( id, print_chat, "%s Nu mai poti folosi urmatoarele comenzi: say, say_team, voice speak", get_tag( ) ); return 1; } } } return 0; } public CommandGag( id ) { if( !( get_user_flags( id ) & COMMAND_ACCESS ) ) { client_cmd( id, "echo %s Nu ai acces la aceasta comanda!", get_tag( ) ); return 1; } new szArg[ 32 ], szMinutes[ 32 ]; read_argv( 1, szArg, charsmax ( szArg ) ); if( equal( szArg, "" ) ) { client_cmd( id, "echo amx_gag < nume > < minute > < motiv >!" ); return 1; } new iPlayer = cmd_target( id, szArg, CMDTARGET_ALLOW_SELF ); if( !iPlayer ) { client_cmd( id, "echo %s Jucatorul specificat nu a fost gasit!", get_tag( ) ); return 1; } if ( get_pcvar_num( gCvarAdminGag ) == 0 ) { if ( is_user_admin( iPlayer ) ) { client_cmd( id, "echo %s Nu poti da gag la Admini!", get_tag( ) ); return 1; } } read_argv( 2, szMinutes, charsmax ( szMinutes ) ); new iMinutes = str_to_num( szMinutes ); if ( iMinutes > get_pcvar_num ( gCvarGagMinuteLimit ) ) { console_print( id, "%s Ai setat %d minute, iar limita maxima de minute este %d! Setare automata pe %d.", get_tag( ), iMinutes, get_pcvar_float ( gCvarGagMinuteLimit ), get_pcvar_float ( gCvarGagMinuteLimit ) ); iMinutes = get_pcvar_num( gCvarGagMinuteLimit ) ; } get_user_name( iPlayer, szName, sizeof ( szName ) -1 ); szOldName[ iPlayer ] = szName; if( PlayerGagged[ iPlayer ] == 1 ) { client_cmd( id, "echo %s Jucatorul %s are deja Gag!", get_tag( ), GetInfo( iPlayer, INFO_NAME ) ); return 1; } if ( get_pcvar_num( gCvarTagName ) == 1 ) { client_cmd( iPlayer, "name ^"%s %s^"", gGagTag, szName ); } PlayerGagged[ iPlayer ] = 1; PlayerGagTime[ iPlayer ] = iMinutes; set_speak( iPlayer, SPEAK_MUTED ); client_print( 0, print_chat, "%s ADMIN %s: Gag %s(%s) pentru %d minute", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), iMinutes ); client_print( iPlayer, print_chat, "%s Ai primit Gag pentru ca ai injurat sau ai facut reclama!", get_tag( ) ); client_print( iPlayer, print_chat, "%s Nu mai poti folosi urmatoarele comenzi: say, say_team, voice speak", get_tag( ) ); return 1; } public CommandUngag( id ) { if( !(get_user_flags( id ) & COMMAND_ACCESS ) ) { client_cmd( id, "echo %s Nu ai acces la aceasta comanda!", get_tag( ) ); return 1; } new szArg[ 32 ]; read_argv( 1, szArg, charsmax( szArg ) ); if( equal( szArg, "" ) ) { client_cmd( id, "echo amx_ungag < nume > !" ); return 1; } new iPlayer = cmd_target ( id, szArg, CMDTARGET_ALLOW_SELF ); if( !iPlayer ) { client_cmd( id, "echo %s Jucatorul specificat nu a fost gasit!", get_tag( ) ); return 1; } if( PlayerGagged[ iPlayer ] == 0 ) { console_print( id, "%s Jucatorul %s nu are Gag!", get_tag( ), GetInfo( iPlayer, INFO_NAME ) ); return 1; } if ( get_pcvar_num ( gCvarTagName ) == 1 ) { client_cmd( iPlayer, "name ^"%s^"", szOldName[ iPlayer ] ); } PlayerGagged[ iPlayer ] = 0; PlayerGagTime[ iPlayer ] = 0; set_speak( iPlayer, SPEAK_NORMAL ); client_print( 0, print_chat, "%s ADMIN %s: Ungag %s(%s|%s)", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ) ); client_print( iPlayer, print_chat, "%s Ai primit Ungag de la adminul: %s, ai grija la limbaj data viitoare!", get_tag( ), GetInfo( id, INFO_NAME ) ); return 1; } public Forward_GagThinker( iEntity ) { if ( pev_valid( iEntity ) ) { set_pev( iEntity, pev_nextthink, get_gametime( ) + 1.0 ) ; new id; for ( id = 1; id <= gMaxPlayers; id++ ) { if ( is_user_connected ( id ) && ! is_user_bot( id ) && PlayerGagged[ id ] == 1 && PlayerGagTime[ id ] > 0 && ( ( get_systime( ) - JoinTime[ id ] ) >= get_pcvar_num ( gCvarGagMinuteInSeconds ) ) ) { JoinTime[ id ] = get_systime( ); PlayerGagTime[ id ] -= 1; if ( PlayerGagTime[ id ] <= 0 ) { PlayerGagTime[ id ] = 0; PlayerGagged[ id ] = 0; set_speak( id, SPEAK_NORMAL ); client_print( id, print_chat, "%s Ai primit UnGag, ai grija la limbaj data viitoare!", get_tag( ) ); client_cmd( id, "name ^"%s^"", szOldName[ id ] ); } } } } } stock SaveGag( id ) { new szIp[ 40 ], szVaultKey[ 64 ], szVaultData[ 64 ]; get_user_ip( id, szIp, charsmax( szIp ) ); formatex( szVaultKey, charsmax( szVaultKey ), "%s-Gag", szIp ); formatex( szVaultData, charsmax( szVaultData ), "%i#%i", PlayerGagged[ id ], PlayerGagTime[ id ] ); nvault_set( gVault, szVaultKey, szVaultData ); } stock LoadGag( id ) { new szIp[ 40 ], szVaultKey[ 64 ], szVaultData[ 64 ]; get_user_ip( id, szIp, charsmax ( szIp ) ); formatex( szVaultKey, charsmax( szVaultKey ), "%s-Gag", szIp ); formatex( szVaultData, charsmax( szVaultData ), "%i#%i", PlayerGagged[ id ], PlayerGagTime[ id ] ); nvault_get( gVault, szVaultKey, szVaultData, charsmax ( szVaultData ) ); replace_all( szVaultData, charsmax( szVaultData ), "#", " " ); new iGagOn[ 32 ], iGagTime [ 32 ]; parse( szVaultData, iGagOn, charsmax ( iGagOn ), iGagTime, charsmax ( iGagTime ) ); PlayerGagged[ id ] = str_to_num ( iGagOn ); PlayerGagTime[ id ] = clamp ( str_to_num ( iGagTime ), 0, get_pcvar_num ( gCvarGagMinuteLimit ) ); } stock GagThinker( ) { new iEntity = create_entity ( "info_target" ); if( ! pev_valid ( iEntity ) ) { return 1; } set_pev ( iEntity, pev_classname, gGagThinkerClassname ); set_pev ( iEntity, pev_nextthink, get_gametime( ) + 1.0 ); return 1; } stock get_tag( ) { new szTag [ 32 ]; get_pcvar_string( gCvarTag, szTag, sizeof ( szTag ) -1 ); return szTag; } stock GetInfo( id, const iInfo ) { new szInfoToReturn[ 64 ]; switch( iInfo ) { case INFO_NAME: { new szName[ 32 ]; get_user_name( id, szName, sizeof ( szName ) -1 ); copy( szInfoToReturn, sizeof ( szInfoToReturn ) -1, szName ); } case INFO_IP: { new szIp[ 32 ]; get_user_ip( id, szIp, sizeof ( szIp ) -1, 1 ); copy( szInfoToReturn, sizeof ( szInfoToReturn ) -1, szIp ); } case INFO_AUTHID: { new szAuthId[ 35 ]; get_user_authid( id, szAuthId, sizeof ( szAuthId ) -1 ); copy( szInfoToReturn, sizeof ( szInfoToReturn ) -1, szAuthId ); } } return szInfoToReturn; } stock bool:UTIL_IsValidMessage( const szSaid[ ] ) { new iLen = strlen( szSaid ); if( !iLen ) { return false; } for( new i = 0; i < iLen; i++ ) { if( szSaid[ i ] != ' ' ) { return true; } } return false; } public plugin_end( ) { nvault_close( gVault ); }
As vrea daca se poate:
- dupa folosirea comenzii sa nu-i modifice numele
- cand scriu amx_gag nume player sa aibe gag 10 minute (default)