View Single Post
Mixtaz
Junior Member
Join Date: Sep 2017
Old 11-03-2023 , 06:22   Re: Restrict FPS of specific player
Reply With Quote #5

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], szFpsOverride];
    
num_to_strMAX_FPSszFpsMaxcharsmaxszFpsMax ) );
    
num_to_strOVERRIDE_STATEszFpsOverridecharsmaxszFpsOverride ) );
    
    
TrieSetStringg_tCvars"fps_max"szFpsMax );
    
TrieSetStringg_tCvars"fps_override"szFpsOverride );
}

public 
plugin_init( )
{
    
register_plugin"Restrict Player FPS"PLUGIN_VERSION"Mixtaz" );
}

public 
plugin_end( ) TrieDestroyg_tCvars );

public 
client_authorizedid )
{
    static 
szAuthID[24];
    
get_user_authid(idszAuthIDcharsmax(szAuthID))

    if(
isThreat(szAuthID))
        
initPlayerCheck(id)
}

public 
initPlayerCheck(id)
{
    
query_client_cvarid"fps_max""PlayerPunish" );
    
query_client_cvarid"fps_override""PlayerPunish" );

    
set_taskTASK_FREQ"initPlayerCheck"id__"b" );
}

public 
PlayerPunishid, const szCvar[ ], const szValue[ ] )

    new 
szValueCheck], szReason128 ];
    new 
userid get_user_userid(id);
    
TrieGetStringg_tCvarsszCvarszValueCheckcharsmaxszValueCheck ) );
    
    new 
iValue str_to_numszValue );
    
    if( 
equalszCvar"fps_max" ) )
    {    
        if( 
iValue MAX_FPS )
        {
            
formatexszReasoncharsmaxszReason ), "Ustaw komende fps_max na %i!"MAX_FPS );
            
            
server_cmd("kick #%d ^"%s^""useridszReason);
        }
    }
    
    else if( 
equalszCvar"fps_override" ) )
    {
        if( 
iValue != OVERRIDE_STATE )
        {
            
formatexszReasoncharsmaxszReason ), "Ustaw komende fps_override na %i!"OVERRIDE_STATE );
            
            
server_cmd("kick #%d ^"%s^""useridszReason);
        }
    }
    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
Mixtaz is offline