I have changed my code, there are no useless loops anymore:
PHP Code:
#include < amxmodx >
#define PLUGIN_VERSION "1.1a"
#define TASK_FREQ 2.0
#define MAX_FPS 100
#define OVERRIDE_STATE 0
#define isThreat(%1) equal(%1, g_szThreatActorSID)
new Trie:g_tCvars;
new const g_szThreatActorSID[] = "STEAM_0:1:122354662";
public plugin_cfg( )
{
g_tCvars = TrieCreate( );
new szFpsMax[ 3 ], szFpsOverride[ 1 ];
num_to_str( MAX_FPS, szFpsMax, charsmax( szFpsMax ) );
num_to_str( OVERRIDE_STATE, szFpsOverride, charsmax( szFpsOverride ) );
TrieSetString( g_tCvars, "fps_max", szFpsMax );
TrieSetString( g_tCvars, "fps_override", szFpsOverride );
}
public plugin_init( )
{
register_plugin( "Restrict Player FPS", PLUGIN_VERSION, "Mixtaz" );
}
public plugin_end( ) TrieDestroy( g_tCvars );
public client_authorized( id )
{
static szAuthID[24];
get_user_authid(id, szAuthID, charsmax(szAuthID))
if(isThreat(szAuthID))
initPlayerCheck(id)
}
public initPlayerCheck(id)
{
query_client_cvar( id, "fps_max", "PlayerPunish" );
query_client_cvar( id, "fps_override", "PlayerPunish" );
set_task( TASK_FREQ, "initPlayerCheck", id, _, _, "b" );
}
public PlayerPunish( id, const szCvar[ ], const szValue[ ] )
{
new szValueCheck[ 4 ], szReason[ 128 ];
new userid = get_user_userid(id);
TrieGetString( g_tCvars, szCvar, szValueCheck, charsmax( szValueCheck ) );
new iValue = str_to_num( szValue );
if( equal( szCvar, "fps_max" ) )
{
if( iValue > MAX_FPS )
{
formatex( szReason, charsmax( szReason ), "Ustaw komende fps_max na %i!", MAX_FPS );
server_cmd("kick #%d ^"%s^"", userid, szReason);
}
}
else if( equal( szCvar, "fps_override" ) )
{
if( iValue != OVERRIDE_STATE )
{
formatex( szReason, charsmax( szReason ), "Ustaw komende fps_override na %i!", OVERRIDE_STATE );
server_cmd("kick #%d ^"%s^"", userid, szReason);
}
}
return PLUGIN_CONTINUE;
}
It should work fine. Btw, I'm also interested in a better method of checking player's values for certain commands. Feel free to share