Kz Players Cvars Checker

Started by doktor
25/05/2008 10:20
Page 3 of 3
doktor12/02/2011 13:55

Those values are '.' and '0'

doktor04/03/2011 21:37

Update to version 0.0.4, lt.rat version link is broken.

Added fps_modem 0 check, removed cl_upspeed useless check.

doktor07/05/2013 20:12(edited 07/05/2013 20:18)

New version, checks fps_max 99.5 and fps_override 1 if client has been updated, else checks fps_max 101 :
( plugin needs colorchat plugin 0.3.0 : http://forums.alliedmods.net/showthread.php?p=851160 )

// #define KZLEOD

#include < amxmodx >
#include < fakemeta >
#include < chatcolor >

#if defined KZLEOD
#include < KzLeod/kz >
#include < KzLeod/kz_timer >
#include < KzLeod/kz_buttons >
#endif

#pragma semicolon 1

#define PLUGIN "Kz Cvar Checker"
#define VERSION "0.2.0"

const MAX_CVAR_LENGTH = 18;

enum _:cvarsProps
{
m_szCvarName[MAX_CVAR_LENGTH],
m_iCvarType,
m_szLegalValue[6]
}

enum _:cvarsDatas
{
m_iCvDatType,
m_iCvPos,
m_szCvLegalValue[6]
}

const STUFFCMD_ALLOWED_OLD = 2;

enum
{
STUFFCMD,
DEVELOPER,
LW,
SPEED,
FPS,
FPSOVERRIDE
}

enum
{
BAD_VALUE,
GOOD_VALUE
}

new const g_szCvars[][cvarsProps] =
{
{"cl_filterstuffcmd", STUFFCMD, ""},
{"developer", DEVELOPER, "0.0"},
{"cl_lw", LW, "1.0"},
{"cl_sidespeed", SPEED, "400.0"},
{"cl_backspeed", SPEED, "400.0"},
{"cl_forwardspeed", SPEED, "400.0"},
{"fps_max", FPS, "99.5"},
{"fps_override", FPSOVERRIDE, "1.0"}
};

new Trie:g_tCvarDatas;

new g_bAllowStuffCmd[33 char];

new bool:g_bHasBeenWarned[33][ sizeof(g_szCvars) ];

public plugin_init()
{
register_plugin( PLUGIN, VERSION, "ConnorMcLeod" );
register_logevent("LogEvent_EnteredTheGame", 2, "1=entered the game");

g_tCvarDatas = TrieCreate();
new datas[cvarsDatas];
for(new i; i {
datas[m_iCvDatType] = g_szCvars[m_iCvarType];
datas[m_iCvPos] = i;
copy(datas[m_szCvLegalValue], charsmax(datas[m_szCvLegalValue]), g_szCvars[m_szLegalValue]);
TrieSetArray(g_tCvarDatas, g_szCvars[m_szCvarName], datas, sizeof(datas));
}
}

get_loguser_index()
{
new szLog[80], szName[32];
read_logargv(0, szLog, charsmax(szLog));
parse_loguser(szLog, szName, charsmax(szName));

return get_user_index(szName);
}

public LogEvent_EnteredTheGame()
{
new id = get_loguser_index();
if( id && !is_user_bot(id) && !is_user_hltv(id) )
{
arrayset(g_bHasBeenWarned[id], false, sizeof(g_bHasBeenWarned[]));
query_client_cvar(id, g_szCvars[0][m_szCvarName], "ClientCvarResult");
}
}

public ClientCvarResult(id, const cvar[], const value[])
{
if( !is_user_connected(id) )
{
return;
}

new datas[cvarsDatas];
TrieGetArray(g_tCvarDatas, cvar, datas, sizeof(datas));
new pos = datas[m_iCvPos];
switch( datas[ m_iCvDatType ] )
{
case STUFFCMD:
{
if( value[0] == 'B' )
{
g_bAllowStuffCmd{ id } = STUFFCMD_ALLOWED_OLD;
}
else
{
g_bAllowStuffCmd{ id } = CheckFixedValue(value, "0.0", 1);
}
}
case DEVELOPER:
{
if( !CheckFixedValue(value, "0.0", 1) )
{
BadCvarValue(id, value, cvar, datas[ m_szCvLegalValue ], pos);
}
else
{
g_bHasBeenWarned[id][pos] = false;
}
}
case LW:
{
if( !CheckFixedValue(value, "1.0", 1) )
{
BadCvarValue(id, value, cvar, datas[ m_szCvLegalValue ], pos);
}
else
{
g_bHasBeenWarned[id][pos] = false;
}
}
case SPEED:
{
if( !CheckFixedValue(value, "400.0", 3) )
{
BadCvarValue(id, value, cvar, datas[ m_szCvLegalValue ], pos);
}
else
{
g_bHasBeenWarned[id][pos] = false;
}
}
case FPS:
{
if( g_bAllowStuffCmd{ id } == STUFFCMD_ALLOWED_OLD )
{
if( !CheckFixedValue(value, "101.0", 3) )
{
BadCvarValue(id, value, cvar, "101.0", pos);
}
else
{
g_bHasBeenWarned[id][pos] = false;
}
pos++; // don't check fps_override, it doesn't exist
}
else
{
if( !CheckFixedValue(value, "99.5", 2, true) )
{
BadCvarValue(id, value, cvar, datas[ m_szCvLegalValue ], pos);
}
else
{
g_bHasBeenWarned[id][pos] = false;
}
}
}
case FPSOVERRIDE:
{
if( !CheckFixedValue(value, "1.0", 1) )
{
BadCvarValue(id, value, cvar, datas[ m_szCvLegalValue ], pos);
}
else
{
g_bHasBeenWarned[id][pos] = false;
}
}
}

if( ++pos >= sizeof(g_szCvars) )
{
pos = 0;
}

query_client_cvar(id, g_szCvars[ pos ][m_szCvarName], "ClientCvarResult");
}

CheckFixedValue( const value[], const legalValue[], leftCount, bool:bFpsMax = false )
{
static iLen, c, i;

iLen = strlen(value);

if( bFpsMax )
{
if( iLen < 4 )
{
return BAD_VALUE;
}
else if( iLen == 4 )
{
return equal(value, legalValue);
}
}
else
{
if( iLen < leftCount || iLen == leftCount + 1 )
{
return BAD_VALUE;
}

if( iLen == leftCount )
{
return equal(value, legalValue, leftCount);
}

if( !equal(value, legalValue, leftCount + 2) )
{
return BAD_VALUE;
}
}

// now check if there are other chars than '0'

for(i=leftCount + 2; i {
c = value;
if( !c )
{
return GOOD_VALUE;
}
else if( c != '0' )
{
return BAD_VALUE;
}
}
return GOOD_VALUE;
}

BadCvarValue(id, const value[], const cvar[], const legalValue[], position)
{
if( !g_bHasBeenWarned[id][position] )
{
#if defined KZLEOD
client_print_color(id, Red, "^4[Kz Checker] ^3Bad cvar value ^4%s : ^3%s ^4Legal Value %s ^3(TIMER RESET !!)", cvar, value, legalValue);
#else
client_print_color(id, Red, "^4[Kz Checker] ^3Bad cvar value ^4%s : ^3%s ^4Legal Value %s", cvar, value, legalValue);
#endif
if( g_bAllowStuffCmd{ id } )
{
client_cmd(id, "%s ^"%s^"", cvar, legalValue);
client_print_color(id, Blue, "^4[Kz Checker] ^3Trying to fix");
}
else
{
client_print_color(id, Red, "^4[Kz Checker] ^3You have to fix by yourself typing in console : ^4%s ^"%s^"", cvar, legalValue);
}
g_bHasBeenWarned[id][position] = true;
}
else if( g_bAllowStuffCmd{ id } )
{
client_cmd(id, "%s ^"%s^"", cvar, legalValue);
}
#if !defined KZLEOD
set_pev(id, pev_velocity, 0);
#else
xolent_ljstats_resetjump(id);
kz_reset_timer(id);
#endif
}

#if defined KZLEOD
public client_use_button(id, button)
{
if( button == START )
{
arrayset(g_bHasBeenWarned[id], false, sizeof(g_bHasBeenWarned[]));
}
}
#endif




For those who would want xolent_ljstats_resetjump function, here it is :
stock xolent_ljstats_resetjump(id)
{
static iPluginId = 0, iResetFunc = 0;
if( !iResetFunc )
{
if( !iPluginId )
{
iPluginId = is_plugin_loaded ( "JumpStats Main" );
}
if( iPluginId > 0 )
{
iResetFunc = get_func_id ( "CmdResetJump", iPluginId );
}
else
{
iResetFunc = -1;
}
}
else if( iResetFunc > 0 )
{
callfunc_begin_i(iResetFunc, iPluginId);
callfunc_push_int ( id ) ;
callfunc_end ( );
}
}

Countyzz07/05/2013 22:02

Awesome!

Countyzz08/05/2013 09:47

it's possible to detect players who trying to change their cvars?
Example:
[XJ] County trying to change his/her cvars!!

+

"fps_override", FPSOVERRIDE, "1.0" i think "0" is the legal setting right?

doktor09/05/2013 16:44

Yes, should be possible, but i don't see the purpose of it.
If you use a plugin with a dynamic native that allow ti reset timer or ljstats, put it instead of setting velocity to 0.

If you let fps_override 0, you can set fps_max to whatever value you want, it doesn't takes effect, hence i had 100.5 fps with fps_max 10 or 30 or 99.5 or 120.

sitka mapper VIP27/12/2013 19:10

Can i get this plugin compiled somehow?

Juice29/12/2013 06:38

Originally posted by sitka
Can i get this plugin compiled somehow?

Code (copy from bottom window): http://pastebin.com/fD8TkUP5
Compiler: http://compiler.amx-x.ru/
You know what to do :E

SzczupaK11/07/2014 14:55

Juice can u make this plugin work with nonsteam because for non steam players it says they should have the 101 fps but uq_jumpstats set their fps to 99.5 PLS

vhz11/05/2015 17:16

how i can put colochat in these plugin?

Page 3 of 3

Please log in to post replies.