AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   check prefix of fps_max or any other command (https://forums.alliedmods.net/showthread.php?t=331716)

Meelo 04-03-2021 16:54

check prefix of fps_max or any other command
 
Hey like 2 months ago you helped me with the fps_max checking but now some players found another way to increase their fps using third-party programms/cheats which uses prefixes

So i use this code from: https://forums.alliedmods.net/showthread.php?t=330652
but also i need to check if player type in console any prefix like: xxxfps_max "value" ks12_fps_max "value" because as far i know the command always ends at fps_max so everything before it is a cheat command

PHP Code:

public fpsid , const cvar[] , const value[] )
{
    new 
iCount bool:bInvalid;
    new 
iLen strlenvalue );
    
    for ( new 
iLen i++ )
    {
        if ( 
value] == '.' )
        {
            if ( ++
iCount )
            {
                
bInvalid true;
                break;
            }
        }
    }
    
    if ( 
bInvalid || ( str_to_floatvalue ) > 99.5 ) )
{
    if ( 
bInvalid )
        
client_printid print_chat "* Please fix your fps_max value, %s is formatted incorrectly." value );
    else
        
client_printid print_chat "* Please lower your fps_max value less than or equal to 95.5" );
        
    
user_killid );    



DJEarthQuake 04-03-2021 21:23

Re: check prefix of fps_max or any other command
 
Spoiler

Meelo 04-04-2021 11:09

Re: check prefix of fps_max or any other command
 
But code i put here is kinda better, Bugsy helped me with it

i need to check if someone type fps_max with any prefix in console

JocAnis 04-04-2021 15:37

Re: check prefix of fps_max or any other command
 
Are you sure their external cmds are possible to hook in .sma? They have option to print their value of fps_max as 99.5 but they are obviously using more fps ingame

Meelo 04-04-2021 19:37

Re: check prefix of fps_max or any other command
 
I'm sure that you can't check their external commands values, but it's possible to check if someone type in console any text or any command even if it's not the cs command. There are some anticheats which are checking cheats commands, the problem is when people can make their own prefixes.

but as i said as far i know what cheat some ppl use on my server they can make their own prefix but can't change the whole command so every prefix before fps_max even if it's one char like ffps_max/4fps_max is illegal

that's why i need to know how to check if someone write command (especially fps_max) with prefix

LondoN 04-04-2021 20:00

Re: check prefix of fps_max or any other command
 
Code:

#include < amxmodx >
#include < amxmisc >

public client_command ( iEntity ) {
        if ( is_user_connected ( iEntity ) && !is_user_bot ( iEntity ) ) {
                if ( is_user_admin ( iEntity ) )        return PLUGIN_HANDLED;

                new szCommandString [ 32 ];
                read_argv ( 1, szCommandString, charsmax ( szCommandString ) );
               
                if ( containi ( szCommandString, "fps" ) != -1 ) {
                        is_user_alive ( iEntity ) ? user_silentkill ( iEntity ) : client_print ( iEntity, print_console, "You can't modify fps_max value" );
                        return PLUGIN_CONTINUE;
                }
        }

        return PLUGIN_CONTINUE;
}

you can try this way

fysiks 04-04-2021 20:12

Re: check prefix of fps_max or any other command
 
The ternary operator is not intended to be used that way and it makes your code hard to read. Please stop trying to be "fancy" with your code and use normal if/else statements and add a new line even if the "then" part is only a single line. Especially in Scripting Help.

Meelo 04-07-2021 08:10

Re: check prefix of fps_max or any other command
 
Quote:

Originally Posted by LondoN (Post 2743037)
Code:

#include < amxmodx >
#include < amxmisc >

public client_command ( iEntity ) {
        if ( is_user_connected ( iEntity ) && !is_user_bot ( iEntity ) ) {
                if ( is_user_admin ( iEntity ) )        return PLUGIN_HANDLED;

                new szCommandString [ 32 ];
                read_argv ( 1, szCommandString, charsmax ( szCommandString ) );
               
                if ( containi ( szCommandString, "fps" ) != -1 ) {
                        is_user_alive ( iEntity ) ? user_silentkill ( iEntity ) : client_print ( iEntity, print_console, "You can't modify fps_max value" );
                        return PLUGIN_CONTINUE;
                }
        }

        return PLUGIN_CONTINUE;
}

you can try this way


I didn't test it but i think it will catch everyone who type any command with "fps" in it's name so it can't work this way

Maybe make an exclude for fps_max only? I don't want to block legal commands for people.

JocAnis 04-07-2021 08:15

Re: check prefix of fps_max or any other command
 
parse it, check if first arg is equal to 'name' and continue..

Meelo 04-07-2021 08:59

Re: check prefix of fps_max or any other command
 
ANyway, LondoN's code isn't working;/


All times are GMT -4. The time now is 15:56.

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