AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Configs checker (https://forums.alliedmods.net/showthread.php?t=329855)

LithuanianJack 01-10-2021 11:24

Configs checker
 
Hi. This plugin doesn't allow players using fps_override 1, cl_lw 0 and fps_max >101 (more than 101). But some players are ignored by this plugin and still can use fps_max more than 101 and other prohibited values. What should be changed in the code? Thank you.

PHP Code:

L 12/30/2020 17:34:07Changed PlayerGam3r <> <> Illegal fps_max value9999
L 12
/30/2020 17:34:12Changed PlayerGam3r <> <> Illegal fps_max value9999
L 12
/30/2020 17:34:17Changed PlayerGam3r <> <> Illegal fps_max value9999
L 12
/30/2020 17:34:22Changed PlayerGam3r <> <> Illegal fps_max value9999
L 12
/30/2020 17:34:27Changed PlayerGam3r <> <> Illegal fps_max value9999
L 12
/30/2020 17:34:32Changed PlayerGam3r <> <> Illegal fps_max value9999
L 12
/30/2020 17:34:42Changed PlayerGam3r <> <> Illegal fps_max value9999 

PHP Code:

// C:\Users\Me\Desktop\Compiler\config_checker.sma(81) : warning 213: tag mismatch
// C:\Users\Me\Desktop\Compiler\config_checker.sma(92) : warning 213: tag mismatch
// C:\Users\Me\Desktop\Compiler\config_checker.sma(103) : warning 213: tag mismatch 

PHP Code:

#include <amxmodx>
#include <amxmisc>

#pragma semicolon 1

#define MAX_PLAYERS 32 
#define PLATFORM_MAX_PATH 256

#define LEGALFPS 101
#define LEGALOVERRIDE 0
#define LEGALCL 1

//#define ONE_FILE_LOGGING
/* Uncomment for one file logging */

new g_Time[MAX_PLAYERS 1];
new 
g_Cvar[MAX_PLAYERS 1];
new 
g_szLogsDir[PLATFORM_MAX_PATH];
new 
bool:g_Connected[MAX_PLAYERS 1];

new const 
version        [] =     "0.0.1",
      
plugin        [] =    "cvars",
      
author        [] =     "unknown";


public 
plugin_init()  {      
    
register_plugin(.version         =     version,
            .
plugin_name     =     plugin,
            .
author          =     author    );
                                }

public 
plugin_cfg()
{
    
get_localinfo"amx_logdir"g_szLogsDircharsmax(g_szLogsDir) );
    
add(g_szLogsDircharsmaxg_szLogsDir ), "/CvarProtection");
    
    if( !
dir_exists(g_szLogsDir) )
        
mkdir(g_szLogsDir);
}


public 
client_putinserver(id)
{
    if( 
task_exists(id) )
        
remove_task(id);
    
    
g_Cvar[id] = 0;
    
g_Connected[id] = true;
    
set_task(5.0"fwCvarCheck"id__"b");
}


public 
client_disconnected(id
{    
    if( 
task_exists(id) )
        
remove_task(id);
        
    
g_Cvar[id] = 0;
    
g_Connected[id] = false;
}


public 
fwCvarCheckid 
{
    if ( !
is_valid_player(id) ) 
    {
        return 
PLUGIN_CONTINUE;
    } else {
        
query_client_cvar(id"fps_max",     "fwResult");
        
query_client_cvar(id"fps_override",     "fwResult");
        
query_client_cvar(id"cl_lw",     "fwResult");
    }
    return 
PLUGIN_CONTINUE;
}


public 
fwResultid, const cvar[], const value[] ) 
{
    if( 
g_Connected[id] == true 
    {
        if ((!
strcmp(cvar"fps_max"1)) && (!(str_to_num(value) <= LEGALFPS)) && (!(get_user_flags(id) & ADMIN_CVAR))) 
        {
            new 
iCurrentTime floatroundget_gametime() );
            
            if( 
iCurrentTime >= g_Time[id] ) 
            {
                
g_Cvar[id] = 1;
                
fwIllegalCvar(idcvarvalue);
                
g_Time[id] = iCurrentTime 5;
            }
            
        } else if ( ( !
strcmp(cvar"fps_override"1) ) && ( str_to_num(value) != LEGALOVERRIDE ) && (!(get_user_flags(id) & ADMIN_CVAR)) ) {
            
            new 
iCurrentTime floatroundget_gametime() );
            
            if( 
iCurrentTime >= g_Time[id] ) 
            {
                
g_Cvar[id] = 2;
                
fwIllegalCvar(idcvarvalue);
                
g_Time[id] = iCurrentTime 5;
            }
            
        } else if ( ( !
strcmp(cvar"cl_lw"1) ) && ( str_to_num(value) != LEGALCL ) ) {
            
            new 
iCurrentTime floatroundget_gametime() );
            
            if( 
iCurrentTime >= g_Time[id] ) 
            {
                
g_Cvar[id] = 3;
                
fwIllegalCvar(idcvarvalue);
                
g_Time[id] = iCurrentTime 5;
            }
            
        } 
/*else if( equal(value, "Bad CVAR request") ) {
            
            new iCurrentTime = floatround( get_gametime() );
            
            if( iCurrentTime >= g_Time[id] ) 
            {
                fwBadCvar(id, value);
                g_Time[id] = iCurrentTime + 5;
            }
        }*/
    
} else {
        return 
PLUGIN_CONTINUE;
    }
    return 
PLUGIN_CONTINUE;
}


stock fwIllegalCvarid, const cvar[], const value[] )
{
    new 
IP[35];
    new 
szName[32];
    new 
szAuthID[35];
    
//new uID = get_user_userid(id);
            
    
get_user_name(idszName31);
    
get_user_ipidIPcharsmax(IP), );
    
get_user_authididszAuthIDcharsmax(szAuthID) );
            
    
//client_print_color(0, print_team_red, "^4*^1 %s is using illegal config value! ( ^3%s %s^1 )", szName, cvar, value);
    
    
if(g_Cvar[id] == 1) {
    
client_cmd(id"fps_max 101" );
    
    
client_print_color(idprint_team_red"^4*^1 %s, you are using illegal config: ^3%s %s^1."szNamecvarvalue);
    
    
LogCvars("Changed Player: %s <%s> <%s> Illegal %s value: %s"szNameszAuthIDIPcvarvalue);
    
    }
    
    if(
g_Cvar[id] == 2) {
    
client_cmd(id"fps_override 0" );
    
    
client_print_color(idprint_team_red"^4*^1 %s, you are using illegal config: ^3%s %s^1."szNamecvarvalue);
    
    
LogCvars("Changed Player: %s <%s> <%s> Illegal %s value: %s"szNameszAuthIDIPcvarvalue);
    
    }
    
    else if(
g_Cvar[id] == 3) {
    
client_cmd(id"cl_lw 1" );
    
    
client_print_color(idprint_team_red"^4*^1 %s, you are using illegal config ^3%s %s^1 value! Changed to ^4cl_lw 1^1"szNamecvarvalue);
    
    
LogCvars("Changed Player: %s <%s> <%s> Illegal %s value: %s"szNameszAuthIDIPcvarvalue);
    
    }
                
    
client_cmdid"echo ^"***** Config checker ******^"" );
    
client_cmdid"echo ^"^"" );
    
client_cmdid"echo ^"Illegal config: %%s^""cvarvalue );
    
    if( 
g_Cvar[id] == 1)
        
client_cmdid"echo ^"Maximum value: %%d.^""cvarLEGALFPS );
    else if( 
g_Cvar[id] == 2)
        
client_cmdid"echo ^"Allowed value: %%d.^""cvarLEGALOVERRIDE );
    else if( 
g_Cvar[id] == 3)
        
client_cmdid"echo ^"Allowed value: %%d.^""cvarLEGALOVERRIDE );
        
    
client_cmdid"echo ^"^"" );
    
client_cmdid"echo ^"***** Config checker ******^"" );
    
client_cmdid"echo ^"^"" );
}


/*stock fwBadCvar( id, const value[] )
{
    new IP[35];
    new szName[32];
    new szAuthID[35];
    //new uID = get_user_userid(id);
            
    get_user_name(id, szName, 31);
    get_user_ip( id, IP, charsmax(IP), 1 );
    get_user_authid( id, szAuthID, charsmax(szAuthID) );
    
    client_print_color(0, print_team_red, "^4Warning!^1 %s is using illegal config value! ( ^3%s %s^1 )", szName, cvar, value);
    
    LogCvars("Warned Player: %s <%s> <%s> Query: %s", szName, szAuthID, IP, value);
    
    server_cmd("kick #%d ^"[CvarProtection] Open your console.^"", uID);
    LogCvars("Kicked Player: %s <%s> <%s> Query: %s", szName, szAuthID, IP, value);
                
    client_cmd( id, "echo ^"^"" );
    client_cmd( id, "echo ^"*****************************^"" );
    client_cmd( id, "echo ^"[CvarProtection]^"" );
    client_cmd( id, "echo ^"^"");
    client_cmd( id, "echo ^"Query: (%s)^"", value);
    client_cmd( id, "echo ^"You probably have an alias blocking a cvar.^"" );
    client_cmd( id, "echo ^"This server doesn't allow any changes.^"" );
    client_cmd( id, "echo ^"*****************************^"" );
    client_cmd( id, "echo ^"^"" );
}*/


stock LogCvars( const message_fmt[], any:... )
{
    static 
message[256];
    
vformatmessagesizeof(message) - 1message_fmt);
    
    static 
filename[96];
    
    
#if defined ONE_FILE_LOGGING
    
if( !filename[0] )
    {
        
get_basedirfilenamecharmax(filename) - );
        
addfilenamecharmax(filename) - 1"/logs/CvarProtection/client_cvars.log" );
    }
    
#else
    
static dir[64];
    if( !
dir[0] )
    {
        
get_basedirdirsizeof(dir) - );
        
adddirsizeof(dir) - 1"/logs/CvarProtection" );
    }
    
format_timefilenamesizeof(filename) - 1"%Y.%m.%d" );
    
formatfilenamesizeof(filename) - 1"%s/client_cvars_%s.log"dirfilename );
    
#endif
    
log_amx("%s"message);
    
log_to_file(filename"%s"message);
}


stock is_valid_player(id)
{
    new 
team[16];
    new 
bool:iOutput false;
        
    new 
teamID get_user_team(idteam15);
    
    if (    
teamID == 
    
||     teamID == 
    
||     equal(team"SPECTATOR") )
        
iOutput true;
    
    if( !
is_user_connected(id) )
        
iOutput false;
        
    if( 
is_user_bot(id) )
        
iOutput false;
    
    return 
iOutput;
}

stock ChatColor(const id, const szMessage[], any:...)
{
    static 
szMsg[190], IdMsg;
    
vformat(szMsgcharsmax(szMsg), szMessage3);
    
    if(!
IdMsgIdMsg get_user_msgid("SayText");
    
    
message_begin(MSG_ONEIdMsg, .player id);
    
write_byte(id);
    
write_string(szMsg);
    
message_end();
}

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


Mordekay 01-18-2021 03:37

Re: Configs checker
 
You won't get help here with slowhacking.
If you don't like their settings: kick them
My guess is: for those who this plugin does not work are those with cl_filterstuffcmd 1 to stop guys like you messing with their config.

LondoN 01-18-2021 06:18

Re: Configs checker
 
You can also try with

get_user_info(id, "fps_max", string, len);

OciXCrom 01-18-2021 07:15

Re: Configs checker
 
Quote:

Originally Posted by LondoN (Post 2733070)
You can also try with

get_user_info(id, "fps_max", string, len);

That's not how it works.


All times are GMT -4. The time now is 14:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.