It is currently 19 Nov 2018 12:16






Reply to topic  [ 2 posts ] 
 [Modificare plugin] Special_Admin_Gag 
Author Message
Membru, skill +1
Membru, skill +1
User avatar

Joined: 08 Apr 2014 17:06
Posts: 144
Location: Targu-Jiu
Detinator Steam: Da
Detinator server CS: Da
Fond eXtream: 0
Salut,
Acest gag este pe minute si doresc sa se faca o modificare astfel incat sa nu se mai poata da gag "0", adica permanent, ci cel putin 1 minut.
| Afiseaza codul
/* 

amx_autogag_time 3 // minutele pentru gag cand ia autogag
amx_gag_minute_limit 35 // limita maxima pentru gag minute
amx_gag_minute_in_seconds 60 // minute in secunde
amx_gag_tagname 0 // 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

/gag < nume > < timp in minute > - dai gag unui jucator pentru x minute
/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

*/

#include < amxmodx >
#include < amxmisc >

#include < fakemeta >
#include < engine >
#include < nvault >
#include < CC_ColorChat >

//#pragma semicolon 1
#pragma tabsize 0

#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 bars[ ] = "/";

new command[ ] [ ] =
{
"/gag",
"/ungag"
};

new Caccess[ ] =
{
COMMAND_ACCESS,
COMMAND_ACCESS
};

//new const gGagTag[ ] = "Gag#";
new const gGagFileName[ ] = "gag_words.ini";
//new const gLogFileName[ ] = "GagLog.log";

new const gGagThinkerClassname[ ] = "GagThinker_";

//new const gGaggedSound[ ] = "misc/gag_dat.wav";
//new const gUnGaggedSound[ ] = "misc/gag_scos.wav";

//new const gHalfLifeGaggedSounds[ ][ ] =
//{
//"barney/youtalkmuch.wav",
//"scientist/stopasking.wav",
//"scientist/shutup.wav",
//"scientist/shutup2.wav",
//"hgrunt/silence!.wav"
//};

new PlayerGagged[ MAX_PLAYERS ];
new PlayerGagTime[ MAX_PLAYERS ];
new JoinTime[ MAX_PLAYERS ];
new szName[ 33 ];
new g_reason[ 32 ];

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 iVault;

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" );

register_clcmd( "say", "command_chat" );

GagThinker( );
register_think( gGagThinkerClassname, "Forward_GagThinker" );
register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged");

gCvarSwearGagTime = register_cvar( "amx_autogag_time", "3" ); // minutele pentru gag cand ia autogag
gCvarGagMinuteLimit = register_cvar( "amx_gag_minute_limit", "10" ); // limita maxima pentru gag minute
gCvarGagMinuteInSeconds = register_cvar( "amx_gag_minute_in_seconds", "60" ); // minute in secunde
//gCvarTagName = register_cvar( "amx_gag_tagname", "0" ); // 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

iVault = nvault_open( "GagSystem" );

if( iVault == INVALID_HANDLE )
{
set_fail_state( "nValut returned invalid handle!" );
}

gMaxPlayers = get_maxplayers( );
}

//public plugin_precache( )
//{
//new i;
//for( i = 0; i < sizeof gHalfLifeGaggedSounds; i++ )
//{
//precache_sound( gHalfLifeGaggedSounds[ i ] );
//}

//precache_sound( gGaggedSound );
//precache_sound( gUnGaggedSound );
//}

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 );
//log_to_file( gLogFileName, "Fisierul <%s> nu exista! Creez unul nou acum...", iFile );
}

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 )
{
ColorChat( 0, RED, "^4%s^1 Jucatorul cu gag^4 %s^1, s-a deconectat!", get_tag( ), GetInfo( id, INFO_NAME ) );
//log_to_file( gLogFileName, "[EXIT]Jucatorul cu gag <%s><%s><%s>, s-a deconectat!", GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ), GetInfo( id, INFO_AUTHID ) );
}

JoinTime[ id ] = 0 ;
SaveGagedPlayers( id );
}

public client_connect( id )
{
LoadGagedPlayers( id );
}

public command_chat( index )
{
static szArg[ 192 ], command2[ 192 ];

read_args( szArg, charsmax ( szArg ) );

if( ! szArg [ 0 ] )
return PLUGIN_CONTINUE;

remove_quotes( szArg[0] );

for( new x; x < sizeof command; x++ )
{
if ( equal ( szArg, command [ x ], strlen ( command [ x ] ) ) )
{
if ( get_user_flags ( index ) & Caccess [ x ] )
{
replace( szArg, charsmax ( szArg ), bars, "" );
formatex( command2, charsmax(command2), "amx_%s", szArg );
client_cmd( index, command2 );
}

break;
}
}

return PLUGIN_CONTINUE;
}

public CheckGag( id )
{
new szSaid[ 300 ];

read_args( szSaid, charsmax( szSaid ) );
remove_quotes( szSaid );

if( !UTIL_IsValidMessage( szSaid ) )
{
return PLUGIN_HANDLED;
}

if ( PlayerGagged[ id ] == 1 )
{
PlayerGagged[ id ] = 1;

ColorChat( id, RED, "^4%s^1 Ai primit Gag pentru limbaj sau reclama. Asteapta^4 %d^1 minute!", get_tag( ), PlayerGagTime[ id ] );
//client_cmd( id, "speak ^"%s^"", gHalfLifeGaggedSounds[ random_num( 0, charsmax( gHalfLifeGaggedSounds ) ) ] );

return PLUGIN_HANDLED;
}

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 );

ColorChat( 0, RED, "^3%s^4 %s^1 (^3%s^1)^1 a primit AutoGag pentru limbaj sau reclama!", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ) );
ColorChat( id, RED, "^4%s^1 Ai primit AutoGag pentru injuratura sau reclama! Timpul expira in:^4 %d^1 minute!", get_tag( ), PlayerGagTime[ id ] );
ColorChat( id, RED, "^4%s^1 Nu mai poti folosi urmatoarele comenzi:^4 say^1,^4 say_team^1,^4 voice speak^1,^4 name", get_tag( ) );

// log_to_file( gLogFileName, "[AUTOGAG]<%s><%s><%s> a luat AutoGag pentru ca a injurat sau a facut reclama!", GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ), GetInfo( id, INFO_AUTHID ) );
// client_cmd( id, "speak ^"%s^"", gGaggedSound );

return PLUGIN_HANDLED;
}
}
}

return PLUGIN_CONTINUE;
}

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 ], reason[ 32 ];

read_argv( 1, szArg, charsmax ( szArg ) );
read_argv( 3, reason, sizeof reason - 1 );

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;
}
}

copy( g_reason, 31, reason );
remove_quotes( reason );
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(strlen(reason) < 1)
{
console_print(id,"amx_gag <nume> <minute> <motiv>")
return 1
}

//if ( get_pcvar_num( gCvarTagName ) == 1 )
//{
//client_cmd( iPlayer, "name ^"%s %s %s^"", gGagTag, szName, reason );
//}

PlayerGagged[ iPlayer ] = 1;
PlayerGagTime[ iPlayer ] = iMinutes;
set_speak( iPlayer, SPEAK_MUTED );

ColorChat( 0, RED, "^4%s^1 ADMIN^4 %s:^1 Gag^3 %s^1 pentru^4 %d^1 minute. Motiv: ^4%s", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), iMinutes, reason );
//ColorChat( iPlayer, RED, "^4%s^1 Ai primit Gag pentru ca ai injurat sau ai facut reclama!", get_tag( ) );
ColorChat( iPlayer, RED, "^4%s^1 Nu mai poti folosi urmatoarele comenzi:^4 say^1,^4 say_team^1,^4 voice speak^1,^4 name", get_tag( ) );

//log_to_file( gLogFileName, "[GAG]%s i-a dat gag lui <%s><%s><%s> pentru. <%d> minute", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ), iMinutes );
log_amx("ADMIN <%s>: i-a dat gag lui <%s><%s><%s> pentru <%d> minute. Motiv: <%s>", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ), iMinutes, reason );
//client_cmd( iPlayer, "speak ^"%s^"", gGaggedSound );
SaveGagedPlayers( id );
return PLUGIN_HANDLED;
}

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 );

ColorChat( 0, RED, "^4%s^1 ADMIN^4 %s:^1 Ungag^3 %s", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ) );
ColorChat( iPlayer, RED, "^4%s^1 Ai primit Ungag de la adminul: ^4%s^1, ai grija la limbaj data viitoare!", get_tag( ), GetInfo( id, INFO_NAME ) );

//log_to_file( gLogFileName, "[UNGAG]<%s> i-a dat ungag lui <%s><%s><%s>", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ) );
log_amx("ADMIN <%s>: i-a dat ungag lui <%s><%s><%s>", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ) );
//client_cmd( iPlayer, "speak ^"%s^"", gUnGaggedSound );
SaveGagedPlayers( id );
return PLUGIN_HANDLED;
}

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 );

ColorChat( id, RED, "^4%s^3 Ai primit UnGag, ai grija la limbaj data viitoare!", get_tag( ) );
// log_to_file( gLogFileName, "[AUTOUNGAG]<%s> a primit AutoUnGag!", GetInfo( id, INFO_NAME ) );

// client_cmd( id, "speak ^"%s^"", gUnGaggedSound );
client_cmd( id, "name ^"%s^"", szOldName[ id ] );
}
}
}
}
}



stock GagThinker( )
{
new iEntity = create_entity ( "info_target" );

if( ! pev_valid ( iEntity ) )
{
return PLUGIN_HANDLED;
}

set_pev ( iEntity, pev_classname, gGagThinkerClassname );
set_pev ( iEntity, pev_nextthink, get_gametime( ) + 1.0 );

return PLUGIN_HANDLED;
}

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 LoadGagedPlayers( 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( iVault, 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 ) );

}

public SaveGagedPlayers( 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( iVault, szVaultKey, szVaultData );
}

public plugin_end( )
{
nvault_close( iVault );
}

public ClientUserInfoChanged(id)
{
if( PlayerGagged[ id ] == 1 )
{
static const name[] = "name";
static szOldName[32], szNewName[32];
pev(id, pev_netname, szOldName, charsmax(szOldName));
if( szOldName[0] )
{
get_user_info(id, name, szNewName, charsmax(szNewName));
if( !equal(szOldName, szNewName) )
{
ColorChat( id, RED, "^4%s ^3Schimbare nick interzisa in perioada gag-ului !", get_tag( ) );
set_user_info(id, name, szOldName);
return FMRES_HANDLED;
}
}
}
return FMRES_IGNORED;
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

_________________
Sunt om cu tine, fii om cu mine !


10 Jun 2018 22:32
Profile multumesc WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 08 Apr 2014 17:06
Posts: 144
Location: Targu-Jiu
Detinator Steam: Da
Detinator server CS: Da
Fond eXtream: 0
Am rezolvat..
| Afiseaza codul
/* 

amx_autogag_time 3 // minutele pentru gag cand ia autogag
amx_gag_minute_limit 35 // limita maxima pentru gag minute
amx_gag_minute_in_seconds 60 // minute in secunde
amx_gag_tagname 0 // 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

/gag < nume > < timp in minute > - dai gag unui jucator pentru x minute
/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

*/

#include < amxmodx >
#include < amxmisc >

#include < fakemeta >
#include < engine >
#include < nvault >
#include < CC_ColorChat >

//#pragma semicolon 1
#pragma tabsize 0

#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 bars[ ] = "/";

new command[ ] [ ] =
{
"/gag",
"/ungag"
};

new Caccess[ ] =
{
COMMAND_ACCESS,
COMMAND_ACCESS
};

//new const gGagTag[ ] = "Gag#";
new const gGagFileName[ ] = "gag_words.ini";
//new const gLogFileName[ ] = "GagLog.log";

new const gGagThinkerClassname[ ] = "GagThinker_";

//new const gGaggedSound[ ] = "misc/gag_dat.wav";
//new const gUnGaggedSound[ ] = "misc/gag_scos.wav";

//new const gHalfLifeGaggedSounds[ ][ ] =
//{
//"barney/youtalkmuch.wav",
//"scientist/stopasking.wav",
//"scientist/shutup.wav",
//"scientist/shutup2.wav",
//"hgrunt/silence!.wav"
//};

new PlayerGagged[ MAX_PLAYERS ];
new PlayerGagTime[ MAX_PLAYERS ];
new JoinTime[ MAX_PLAYERS ];
new szName[ 33 ];
new g_reason[ 32 ];

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 iVault;

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" );

register_clcmd( "say", "command_chat" );

GagThinker( );
register_think( gGagThinkerClassname, "Forward_GagThinker" );
register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged");

gCvarSwearGagTime = register_cvar( "amx_autogag_time", "3" ); // minutele pentru gag cand ia autogag
gCvarGagMinuteLimit = register_cvar( "amx_gag_minute_limit", "35" ); // limita maxima pentru gag minute
gCvarGagMinuteInSeconds = register_cvar( "amx_gag_minute_in_seconds", "60" ); // minute in secunde
//gCvarTagName = register_cvar( "amx_gag_tagname", "0" ); // 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

iVault = nvault_open( "GagSystem" );

if( iVault == INVALID_HANDLE )
{
set_fail_state( "nValut returned invalid handle!" );
}

gMaxPlayers = get_maxplayers( );
}

//public plugin_precache( )
//{
//new i;
//for( i = 0; i < sizeof gHalfLifeGaggedSounds; i++ )
//{
//precache_sound( gHalfLifeGaggedSounds[ i ] );
//}

//precache_sound( gGaggedSound );
//precache_sound( gUnGaggedSound );
//}

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 );
//log_to_file( gLogFileName, "Fisierul <%s> nu exista! Creez unul nou acum...", iFile );
}

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 )
{
ColorChat( 0, RED, "^4%s^1 Jucatorul cu gag^4 %s^1, s-a deconectat!", get_tag( ), GetInfo( id, INFO_NAME ) );
//log_to_file( gLogFileName, "[EXIT]Jucatorul cu gag <%s><%s><%s>, s-a deconectat!", GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ), GetInfo( id, INFO_AUTHID ) );
}

JoinTime[ id ] = 0 ;
SaveGagedPlayers( id );
}

public client_connect( id )
{
LoadGagedPlayers( id );
}

public command_chat( index )
{
static szArg[ 192 ], command2[ 192 ];

read_args( szArg, charsmax ( szArg ) );

if( ! szArg [ 0 ] )
return PLUGIN_CONTINUE;

remove_quotes( szArg[0] );

for( new x; x < sizeof command; x++ )
{
if ( equal ( szArg, command [ x ], strlen ( command [ x ] ) ) )
{
if ( get_user_flags ( index ) & Caccess [ x ] )
{
replace( szArg, charsmax ( szArg ), bars, "" );
formatex( command2, charsmax(command2), "amx_%s", szArg );
client_cmd( index, command2 );
}

break;
}
}

return PLUGIN_CONTINUE;
}

public CheckGag( id )
{
new szSaid[ 300 ];

read_args( szSaid, charsmax( szSaid ) );
remove_quotes( szSaid );

if( !UTIL_IsValidMessage( szSaid ) )
{
return PLUGIN_HANDLED;
}

if ( PlayerGagged[ id ] == 1 )
{
PlayerGagged[ id ] = 1;

ColorChat( id, RED, "^4%s^1 Ai primit Gag pentru limbaj sau reclama. Asteapta^4 %d^1 minute!", get_tag( ), PlayerGagTime[ id ] );
//client_cmd( id, "speak ^"%s^"", gHalfLifeGaggedSounds[ random_num( 0, charsmax( gHalfLifeGaggedSounds ) ) ] );

return PLUGIN_HANDLED;
}

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 );

ColorChat( 0, RED, "^3%s^4 %s^1 (^3%s^1)^1 a primit AutoGag pentru limbaj sau reclama!", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ) );
ColorChat( id, RED, "^4%s^1 Ai primit AutoGag pentru injuratura sau reclama! Timpul expira in:^4 %d^1 minute!", get_tag( ), PlayerGagTime[ id ] );
ColorChat( id, RED, "^4%s^1 Nu mai poti folosi urmatoarele comenzi:^4 say^1,^4 say_team^1,^4 voice speak^1,^4 name", get_tag( ) );

// log_to_file( gLogFileName, "[AUTOGAG]<%s><%s><%s> a luat AutoGag pentru ca a injurat sau a facut reclama!", GetInfo( id, INFO_NAME ), GetInfo( id, INFO_IP ), GetInfo( id, INFO_AUTHID ) );
// client_cmd( id, "speak ^"%s^"", gGaggedSound );

return PLUGIN_HANDLED;
}
}
}

return PLUGIN_CONTINUE;
}

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 ], reason[ 32 ];

read_argv( 1, szArg, charsmax ( szArg ) );
read_argv( 3, reason, sizeof reason - 1 );

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;
}
}

copy( g_reason, 31, reason );
remove_quotes( reason );
read_argv( 2, szMinutes, charsmax ( szMinutes ) );

new iMinutes = clamp(str_to_num(szMinutes), 1, 35);

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(strlen(reason) < 1)
{
console_print(id,"amx_gag <nume> <minute> <motiv>")
return 1
}

//if ( get_pcvar_num( gCvarTagName ) == 1 )
//{
//client_cmd( iPlayer, "name ^"%s %s %s^"", gGagTag, szName, reason );
//}

PlayerGagged[ iPlayer ] = 1;
PlayerGagTime[ iPlayer ] = iMinutes;
set_speak( iPlayer, SPEAK_MUTED );

ColorChat( 0, RED, "^4%s^1 ADMIN^4 %s:^1 Gag^3 %s^1 pentru^4 %d^1 minute. Motiv: ^4%s", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), iMinutes, reason );
//ColorChat( iPlayer, RED, "^4%s^1 Ai primit Gag pentru ca ai injurat sau ai facut reclama!", get_tag( ) );
ColorChat( iPlayer, RED, "^4%s^1 Nu mai poti folosi urmatoarele comenzi:^4 say^1,^4 say_team^1,^4 voice speak^1,^4 name", get_tag( ) );

//log_to_file( gLogFileName, "[GAG]%s i-a dat gag lui <%s><%s><%s> pentru. <%d> minute", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ), iMinutes );
log_amx("ADMIN <%s>: i-a dat gag lui <%s><%s><%s> pentru <%d> minute. Motiv: <%s>", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ), iMinutes, reason );
//client_cmd( iPlayer, "speak ^"%s^"", gGaggedSound );
SaveGagedPlayers( id );
return PLUGIN_HANDLED;
}

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 );

ColorChat( 0, RED, "^4%s^1 ADMIN^4 %s:^1 Ungag^3 %s", get_tag( ), GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ) );
ColorChat( iPlayer, RED, "^4%s^1 Ai primit Ungag de la adminul: ^4%s^1, ai grija la limbaj data viitoare!", get_tag( ), GetInfo( id, INFO_NAME ) );

//log_to_file( gLogFileName, "[UNGAG]<%s> i-a dat ungag lui <%s><%s><%s>", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ) );
log_amx("ADMIN <%s>: i-a dat ungag lui <%s><%s><%s>", GetInfo( id, INFO_NAME ), GetInfo( iPlayer, INFO_NAME ), GetInfo( iPlayer, INFO_IP ), GetInfo( iPlayer, INFO_AUTHID ) );
//client_cmd( iPlayer, "speak ^"%s^"", gUnGaggedSound );
SaveGagedPlayers( id );
return PLUGIN_HANDLED;
}

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 );

ColorChat( id, RED, "^4%s^3 Ai primit UnGag, ai grija la limbaj data viitoare!", get_tag( ) );
// log_to_file( gLogFileName, "[AUTOUNGAG]<%s> a primit AutoUnGag!", GetInfo( id, INFO_NAME ) );

// client_cmd( id, "speak ^"%s^"", gUnGaggedSound );
client_cmd( id, "name ^"%s^"", szOldName[ id ] );
}
}
}
}
}



stock GagThinker( )
{
new iEntity = create_entity ( "info_target" );

if( ! pev_valid ( iEntity ) )
{
return PLUGIN_HANDLED;
}

set_pev ( iEntity, pev_classname, gGagThinkerClassname );
set_pev ( iEntity, pev_nextthink, get_gametime( ) + 1.0 );

return PLUGIN_HANDLED;
}

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 LoadGagedPlayers( 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( iVault, 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 ) );

}

public SaveGagedPlayers( 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( iVault, szVaultKey, szVaultData );
}

public plugin_end( )
{
nvault_close( iVault );
}

public ClientUserInfoChanged(id)
{
if( PlayerGagged[ id ] == 1 )
{
static const name[] = "name";
static szOldName[32], szNewName[32];
pev(id, pev_netname, szOldName, charsmax(szOldName));
if( szOldName[0] )
{
get_user_info(id, name, szNewName, charsmax(szNewName));
if( !equal(szOldName, szNewName) )
{
ColorChat( id, RED, "^4%s ^3Schimbare nick interzisa in perioada gag-ului !", get_tag( ) );
set_user_info(id, name, szOldName);
return FMRES_HANDLED;
}
}
}
return FMRES_IGNORED;
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Se poate inchide !

_________________
Sunt om cu tine, fii om cu mine !


16 Jun 2018 18:07
Profile multumesc WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: Aneimar and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

În cazul în care aveți probleme cu contul trimiteți un email sau mesaj la servicii_extream[arond]yahoo[punct]com

Powered by phpBB® Forum Software © phpBB Group