Raised This Month: $183 Target: $400
 45% 

index out of bounds problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Meelo
Junior Member
Join Date: Aug 2010
Old 01-13-2021 , 10:21   index out of bounds problem
Reply With Quote #1

Hello, i need help to repair this error

L 01/13/2021 - 133:44: [AMXX] Run time error 4: index out of bounds
L 01/13/2021 - 133:44: [AMXX] [0] ranticheat.sma:layer_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];

Last edited by Meelo; 01-13-2021 at 10:22.
Meelo is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-13-2021 , 10:22   Re: index out of bounds problem
Reply With Quote #2

Show how the variables are defined.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-13-2021 , 10:39   Re: index out of bounds problem
Reply With Quote #3

better yet show the full code.

since averagefpsnum has a possibility of returning an invalid cell id.
__________________
@Jailbreak Main Mod v2.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Meelo
Junior Member
Join Date: Aug 2010
Old 01-13-2021 , 11:16   Re: index out of bounds problem
Reply With Quote #4

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

new Float:UserFPS[33]
I've added .sma below, it's public kz/hidenseek anticheat
Attached Files
File Type: sma Get Plugin or Get Source (ranticheat.sma - 7 views - 60.7 KB)
Meelo is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 01-13-2021 , 15:06   Re: index out of bounds problem
Reply With Quote #5

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.
__________________
A little of scripting makes a MIRACLE.
=============================================
DeclineD#7346 // for everyone who wants a friend..
AnimalMonster is offline
Meelo
Junior Member
Join Date: Aug 2010
Old 01-14-2021 , 13:09   Re: index out of bounds problem
Reply With Quote #6

Im not a scripter so yes, i didn't notice it. I'll check if it works.
Meelo is offline
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 08:07.


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