AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   index out of bounds problem (https://forums.alliedmods.net/showthread.php?t=329917)

Meelo 01-13-2021 09:21

index out of bounds problem
 
Hello, i need help to repair this error

L 01/13/2021 - 13:33:44: [AMXX] Run time error 4: index out of bounds
L 01/13/2021 - 13:33:44: [AMXX] [0] ranticheat.sma::Player_PostThink (line 479)

Code:

public Player_PostThink( id ) {
        if( !is_user_alive( id ) || pev( id, pev_flags ) & FL_FROZEN || pev( id, pev_maxspeed ) < 210.0 || pev( id, pev_maxspeed ) > 260 || ( get_user_team( id ) != 1 && get_user_team( id ) != 2 )
        || is_user_bot( id ) || bPluginPause || bBanned[id] )
                return;
       
        /*&& pev( id, pev_button ) & IN_DUCK*/ /*|| pev( id, pev_movetype ) & ( MOVETYPE_FLY | MOVETYPE_NOCLIP )*/
       
        static buttons, oldbuttons[33];
        buttons = pev( id, pev_button );
       
        static Float:MovementSqroot;
        MovementSqroot = floatsqroot( flForwardMove[id] * flForwardMove[id] + flSideMove[id] * flSideMove[id] );
       
        // Check FPS
        static fpsdet[33];
       
        if( UserFPS[id] > 101.0 || UserFPS[id] <= 19.89 ) {
                if( ++fpsdet[id] >= 100 ) {
                        new name[32], SteamID[32], IPaddr[32];
                        get_user_name( id, name, charsmax( name ) );
                        get_user_authid( id, SteamID, charsmax( SteamID ) );
                        get_user_ip( id, IPaddr, charsmax( IPaddr ), 1 );
                       
                        fpsdet[id] = 0;
                       
                        log_to_file( "rAntiCheat.log", "FPS %f detected on player %s, IP: %s, SteamID: %s", UserFPS[id], name, IPaddr, SteamID );
                       
                        bBanned[id] = true;
                       
                        //server_cmd( "amx_mban #%d 120 ^"[^x03rAnti-Cheat^x01] FPS %.2f detected!^"", get_user_userid( id ), UserFPS[id] );
                }
        } else
                fpsdet[id] = 0;
        // ---------------------
       
        static Float:fSpeed[3];
        pev( id, pev_velocity, fSpeed );
       
        if( UserFPS[id] > 48.0 && UserFPS[id] < 101.0 ) {
                AVGFPS[id][0] += UserFPS[id];
                ++AVGFPS[id][1];
        }
       
        // JB detection
        if( bWouldTakeDMG[id] ) {
                if( distance_to_ground( id ) < ( fSpeed[2] / -10.0 ) ) {       
                        averagefps[id] += UserFPS[id];
                        FPSToAverage[id][averagefpsnum[id]] = UserFPS[id];
                        DistToAvg[id][averagefpsnum[id]] = distance_to_ground( id );
                        ++averagefpsnum[id];
                }

Line 479:
Code:

FPSToAverage[id][averagefpsnum[id]] = UserFPS[id];

OciXCrom 01-13-2021 09:22

Re: index out of bounds problem
 
Show how the variables are defined.

Natsheh 01-13-2021 09:39

Re: index out of bounds problem
 
better yet show the full code.

since averagefpsnum has a possibility of returning an invalid cell id.

Meelo 01-13-2021 10:16

Re: index out of bounds problem
 
1 Attachment(s)
Code:

new averagefpsnum[33];
new Float:FPSToAverage[33][32];

new Float:UserFPS[33]

I've added .sma below, it's public kz/hidenseek anticheat

AnimalMonster 01-13-2021 14:06

Re: index out of bounds problem
 
Well, haven't you noticed that fps cand be over 100? And the second array is 32?
That s the problem.. set 32 to 102 and should compile.

Meelo 01-14-2021 12:09

Re: index out of bounds problem
 
Im not a scripter so yes, i didn't notice it. I'll check if it works.


All times are GMT -4. The time now is 14:06.

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