/* Formatright © 2012 CheckCvars v1.0 Author: OvidiuS *English* This plugin is free software; you can modify it under the terms of the GNU General Public License as published by the Free Software Foundation. *Serbian* Ovaj plugin je besplatni program; mozete ga menjati postujuci prava autora, samo ga ne smete prodavati. Svako krsenje GNU Licence moze da rezultitra tuzbom. */ #include #include new Array:g_aCvars, Trie:g_tCvarName; new g_szCvarFile[ 64 ]; public plugin_init() { register_plugin("CvarCheck", "1.0", "OvidiuS"); register_cvar("checkcvars" , "1.0" , (FCVAR_SERVER|FCVAR_SPONLY)) get_configsdir( g_szCvarFile, charsmax( g_szCvarFile ) ); add( g_szCvarFile, charsmax( g_szCvarFile ), "/cvarovi.ini"); set_task( 10.0, "CheckCvars", _, _, _, "b" ); ReadCvarsFile( ); } public plugin_end( ) { TrieDestroy( g_tCvarName ); ArrayDestroy( g_aCvars ); } ReadCvarsFile() { if( !file_exists( g_szCvarFile ) ) { write_file( g_szCvarFile, ";Ime Cvara | Min. vrednost | Srednja vrednost | Max. vrednost"); write_file( g_szCvarFile, "rate 18000 20000 25000" ); write_file( g_szCvarFile, "fps_max 100 100 100" ); } new iFile = fopen( g_szCvarFile, "rt" ); if( !iFile ) return; g_aCvars = ArrayCreate( 256 ); g_tCvarName = TrieCreate( ); new szBuffer[ 128 ], szCvar[ 48 ], iPosition; while( !feof( iFile ) ) { fgets( iFile, szBuffer, charsmax( szBuffer ) ); if( !szBuffer[ 0 ] || szBuffer[ 0 ] == '#' || szBuffer[ 0 ] == '/' || szBuffer[ 0 ] == ';' ) continue; parse( szBuffer, szCvar, charsmax( szCvar ) ); TrieSetCell( g_tCvarName, szCvar, iPosition ); ArrayPushString( g_aCvars, szBuffer ); iPosition++; } fclose( iFile ); } public CheckCvars( ) { new iAllPlayers[ 32 ], iAllCount; get_players(iAllPlayers, iAllCount, "ch") if( iAllCount ) { new szBuffer[ 128 ], szCvar[ 48 ]; new iCvarsNum = ArraySize( g_aCvars ); for( --iAllCount; iAllCount >= 0; iAllCount-- ) { new iPlayer = iAllPlayers[ iAllCount ] for( --iCvarsNum; iCvarsNum >= 0; iCvarsNum-- ) { ArrayGetString( g_aCvars, iCvarsNum, szBuffer, charsmax( szBuffer ) ); parse( szBuffer, szCvar, charsmax( szCvar ) ); query_client_cvar( iPlayer, szCvar, "CvarResult_48" ); } } } } public CvarResult_48( iPlayer, const Cvar[ ], const Value[ ] ) { static iArrayPosition; if( TrieGetCell( g_tCvarName, Cvar, iArrayPosition ) ) { new Float:iValue, Float:iMin, Float:iMax; new szBuffer[ 128 ], szCvar[ 48 ], szValue[ 32 ], szMin[ 32 ], szMax[ 32 ]; ArrayGetString( g_aCvars, iArrayPosition, szBuffer, charsmax( szBuffer ) ); parse( szBuffer, szCvar, charsmax( szCvar ), szMin, charsmax( szMin ), szValue, charsmax( szValue ), szMax, charsmax( szMax ) ); iValue = str_to_float( Value ); iMin = str_to_float( szMin ); iMax = str_to_float( szMax ); if( iValue < iMin || iValue > iMax ) client_cmd( iPlayer, "%s %s", szCvar, szValue ); } }