//#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.2"
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) ];
new bool:g_bOn;
public plugin_precache()
{
g_bOn = false;
}
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<sizeof(g_szCvars); 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));
}
g_bOn = true;
}
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()
{
if( !g_bOn )
{
return;
}
new id = get_loguser_index();
if( id && is_user_connected(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( !g_bOn )
{
return;
}
if( !is_user_connected(id) || is_user_connecting(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<iLen; 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( !g_bOn )
{
return;
}
if( button == START )
{
arrayset(g_bHasBeenWarned[id], false, sizeof(g_bHasBeenWarned[]));
}
}
#endif
#include <amxmodx>
#include <fakemeta>
public plugin_init()
{
register_plugin("Fps Checker", "0.1", "Dev-CS.ru")
register_forward(FM_PlayerPreThink, "PreThink");
}
new Fps[33];
new Float:LastCheck[33];
new Frames[33];
new Warnings[33];
public client_connect(id)
{
Warnings[id] = 0;
LastCheck[id] = 0.0;
}
public PreThink(id)
{
if(LastCheck[id] <= get_gametime())
{
Fps[id] = Frames[id];
if(Fps[id] > 101)
{
if(++Warnings[id] > 3)
{
kick_user(id, "100+ fps");
}
}
Frames[id] = 0;
LastCheck[id] = get_gametime() + 1.0;
}
Frames[id]++;
}
stock kick_user(id, szReason[])
{
new iUserId = get_user_userid(id);
server_cmd("kick #%d ^"%s^"", iUserId, szReason)
return 1
}
C++://#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.2"
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) ];
new bool:g_bOn;
public plugin_precache()
{
g_bOn = false;
}
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<sizeof(g_szCvars); 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));
}
g_bOn = true;
}
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()
{
if( !g_bOn )
{
return;
}
new id = get_loguser_index();
if( id && is_user_connected(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( !g_bOn )
{
return;
}
if( !is_user_connected(id) || is_user_connecting(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<iLen; 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( !g_bOn )
{
return;
}
if( button == START )
{
arrayset(g_bHasBeenWarned[id], false, sizeof(g_bHasBeenWarned[]));
}
}
#endif
//#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.2"
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) ];
new bool:g_bOn;
public plugin_precache()
{
g_bOn = false;
}
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<sizeof(g_szCvars); 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));
}
g_bOn = true;
}
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()
{
if( !g_bOn )
{
return;
}
new id = get_loguser_index();
if( id && is_user_connected(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( !g_bOn )
{
return;
}
if( !is_user_connected(id) || is_user_connecting(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<iLen; 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( !g_bOn )
{
return;
}
if( button == START )
{
arrayset(g_bHasBeenWarned[id], false, sizeof(g_bHasBeenWarned[]));
}
}
#endif
++UPКак переписать в kz_cheaker'e чтобы не конкретное значение разрешал и исправлял, а диапозон, мне нужно допустимое значение ФПС не более 120? Как сделать?