Raised This Month: $12 Target: $400
 3% 

Restrict FPS of specific player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mixtaz
Junior Member
Join Date: Sep 2017
Old 10-26-2023 , 04:25   Restrict FPS of specific player
Reply With Quote #1

Hello everyone. I have rather peculiar problem. There is a guy on my server who is playing on very high fps and he is doing something called SGS (stand-up ground strafing) and some sort of parachute shenaningans.

He is ruining experience for some of the players and I want to force limit his FPS to 100. I've made an attempt to make a plugin that stops him, but for some reason whenever he joins it also automatically kicks everyone whose fps is above 100.

But in this case he is the only threat actor here so I only care that he has 100 FPS max. Here is the code I've made:

PHP Code:
#include < amxmodx >

#define PLUGIN_VERSION "1.1"

#define TASK_FREQ 2.0 

#define isThreat(%1) equal(%1, g_szThreatActorSID)

new Trie:g_tCvars;

const 
g_iFpsMax 100;
const 
g_iFpsOverride 0;

new const 
g_szThreatActorSID[] = "STEAM_0:1:122354662";
new 
g_szAuthID32 ]

public 
plugin_cfg( )
{
    
g_tCvars TrieCreate( );

    new 
szFpsMax], szFpsOverride];
    
num_to_strg_iFpsMaxszFpsMaxcharsmaxszFpsMax ) );
    
num_to_strg_iFpsOverrideszFpsOverridecharsmaxszFpsOverride ) );
    
    
TrieSetStringg_tCvars"fps_max"szFpsMax );
    
TrieSetStringg_tCvars"fps_override"szFpsOverride );
    
    
set_taskTASK_FREQ"OnTaskCheckCvars"___"b" );
}

public 
plugin_init( )
{
    
register_plugin"Fps Limit"PLUGIN_VERSION"DoNii x Mixtaz" );
    
register_cvar"fps_limit_cvar"PLUGIN_VERSIONFCVAR_SERVER FCVAR_SPONLY );
}

public 
plugin_end( )
TrieDestroyg_tCvars );

public 
client_authorizedid )
{
    
get_user_authid(idg_szAuthIDcharsmax(g_szAuthID))

    if(
isThreat(g_szAuthID))
        
client_printidprint_console"Ustaw komendy fps_max 100 i fps_override 0!" );
}

public 
OnTaskCheckCvars( )
{
    new 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"c" );
    static 
iTempID;

    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        if(
isThreat(g_szAuthID))
        {
            
query_client_cvariTempID"fps_max""OnCvarResult" );
            
query_client_cvariTempID"fps_override""OnCvarResult" );
        }
    }
}

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

    new 
szValueCheck], szReason128 ];
    
TrieGetStringg_tCvarsszCvarszValueCheckcharsmaxszValueCheck ) );
    
    new 
iValue str_to_numszValue );
    
    if( 
equalszCvar"fps_max" ) )
    {    
        if( 
iValue g_iFpsMax )
        {
            
formatexszReasoncharsmaxszReason ), "^n***************************^n** Ustaw komendy fps_max 100 i fps_override 0! ^n***************************"g_iFpsMax );
            
            
server_cmd"kick #%d"get_user_useridid ));
            
client_printidprint_consoleszReason );
        }
    }
    
    else if( 
equalszCvar"fps_override" ) )
    {
        if( 
iValue != g_iFpsOverride )
        {
            
formatexszReasoncharsmaxszReason ), "^n***************************^n** Ustaw komendy fps_max 100 i fps_override 0! <- **^n***************************"g_iFpsOverride );
            
            
server_cmd"kick #%d"get_user_useridid ));
            
client_printidprint_consoleszReason );
        }
    }
    return 
PLUGIN_CONTINUE;

Mixtaz is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-26-2023 , 10:15   Re: Restrict FPS of specific player
Reply With Quote #2

You're executing query_client_cvar() on all players instead of the threath itself. Don't loop through all player, just target the threat itself and act accordingly.

PHP Code:
public OnTaskCheckCvars( )
{
    new 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"c" );
    static 
iTempID;

    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        if(
isThreat(g_szAuthID))
        {
            
query_client_cvariTempID"fps_max""OnCvarResult" );
            
query_client_cvariTempID"fps_override""OnCvarResult" );
        }
    }

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 10-30-2023 , 08:23   Re: Restrict FPS of specific player
Reply With Quote #3

cvars can be faked, instead there are better ways to check for high fps.
__________________
deprale is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 10-30-2023 , 13:17   Re: Restrict FPS of specific player
Reply With Quote #4

@deprale show us your cards
__________________
mlibre is offline
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
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 11-04-2023 , 07:37   Re: Restrict FPS of specific player
Reply With Quote #6

The script has 2 methods. Feel free to use or cannibalize.

https://github.com/djearthquake/amxx...eck_finale.sma
DJEarthQuake is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 11-04-2023 , 08:15   Re: Restrict FPS of specific player
Reply With Quote #7

query_client_cvar not is very reliable I read it for there
__________________
mlibre is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 11-15-2023 , 06:16   Re: Restrict FPS of specific player
Reply With Quote #8

in client_PreThink, measure the time between current think and last think to get accurate player fps
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode