Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
|
01-10-2021
, 11:24
Configs checker
|
#1
|
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:07: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
L 12/30/2020 - 17:34:12: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
L 12/30/2020 - 17:34:17: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
L 12/30/2020 - 17:34:22: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
L 12/30/2020 - 17:34:27: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
L 12/30/2020 - 17:34:32: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
L 12/30/2020 - 17:34:42: Changed Player: Gam3r <> <> Illegal fps_max value: 9999
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_szLogsDir, charsmax(g_szLogsDir) );
add(g_szLogsDir, charsmax( g_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 fwCvarCheck( id )
{
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 fwResult( id, 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 = floatround( get_gametime() );
if( iCurrentTime >= g_Time[id] )
{
g_Cvar[id] = 1;
fwIllegalCvar(id, cvar, value);
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 = floatround( get_gametime() );
if( iCurrentTime >= g_Time[id] )
{
g_Cvar[id] = 2;
fwIllegalCvar(id, cvar, value);
g_Time[id] = iCurrentTime + 5;
}
} else if ( ( !strcmp(cvar, "cl_lw", 1) ) && ( str_to_num(value) != LEGALCL ) ) {
new iCurrentTime = floatround( get_gametime() );
if( iCurrentTime >= g_Time[id] )
{
g_Cvar[id] = 3;
fwIllegalCvar(id, cvar, value);
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 fwIllegalCvar( id, const cvar[], 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, "^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(id, print_team_red, "^4*^1 %s, you are using illegal config: ^3%s %s^1.", szName, cvar, value);
LogCvars("Changed Player: %s <%s> <%s> Illegal %s value: %s", szName, szAuthID, IP, cvar, value);
}
if(g_Cvar[id] == 2) {
client_cmd(id, "fps_override 0" );
client_print_color(id, print_team_red, "^4*^1 %s, you are using illegal config: ^3%s %s^1.", szName, cvar, value);
LogCvars("Changed Player: %s <%s> <%s> Illegal %s value: %s", szName, szAuthID, IP, cvar, value);
}
else if(g_Cvar[id] == 3) {
client_cmd(id, "cl_lw 1" );
client_print_color(id, print_team_red, "^4*^1 %s, you are using illegal config ^3%s %s^1 value! Changed to ^4cl_lw 1^1", szName, cvar, value);
LogCvars("Changed Player: %s <%s> <%s> Illegal %s value: %s", szName, szAuthID, IP, cvar, value);
}
client_cmd( id, "echo ^"***** Config checker ******^"" );
client_cmd( id, "echo ^"^"" );
client_cmd( id, "echo ^"Illegal config: %s %s^"", cvar, value );
if( g_Cvar[id] == 1)
client_cmd( id, "echo ^"Maximum value: %s %d.^"", cvar, LEGALFPS );
else if( g_Cvar[id] == 2)
client_cmd( id, "echo ^"Allowed value: %s %d.^"", cvar, LEGALOVERRIDE );
else if( g_Cvar[id] == 3)
client_cmd( id, "echo ^"Allowed value: %s %d.^"", cvar, LEGALOVERRIDE );
client_cmd( id, "echo ^"^"" );
client_cmd( id, "echo ^"***** Config checker ******^"" );
client_cmd( id, "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];
vformat( message, sizeof(message) - 1, message_fmt, 2 );
static filename[96];
#if defined ONE_FILE_LOGGING
if( !filename[0] )
{
get_basedir( filename, charmax(filename) - 1 );
add( filename, charmax(filename) - 1, "/logs/CvarProtection/client_cvars.log" );
}
#else
static dir[64];
if( !dir[0] )
{
get_basedir( dir, sizeof(dir) - 1 );
add( dir, sizeof(dir) - 1, "/logs/CvarProtection" );
}
format_time( filename, sizeof(filename) - 1, "%Y.%m.%d" );
format( filename, sizeof(filename) - 1, "%s/client_cvars_%s.log", dir, filename );
#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(id, team, 15);
if ( teamID == 1
|| teamID == 2
|| 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(szMsg, charsmax(szMsg), szMessage, 3);
if(!IdMsg) IdMsg = get_user_msgid("SayText");
message_begin(MSG_ONE, IdMsg, .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 }
*/
|
|