Raised This Month: $32 Target: $400
 8% 

Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-24-2016 , 16:50   Run time error 4: index out of bounds
Reply With Quote #1

Hello,

This is problem function:

Code:
ncod_setUserStatist(id, NCODSTATIST_HEALTH, 20)
Code:
 
L 10/24/2016 - 22:49:09: Start of error session.
L 10/24/2016 - 22:49:09: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20161024.log")
L 10/24/2016 - 22:49:09: [AMXX] Displaying debug trace (plugin "NCodMod_engine.amxx")
L 10/24/2016 - 22:49:09: [AMXX] Run time error 4: index out of bounds 
L 10/24/2016 - 22:49:09: [AMXX]    [0] NCodMod_engine.sma::nativeSetUserStatist (line 1244)
L 10/24/2016 - 22:49:09: Unhandled dynamic native error
L 10/24/2016 - 22:49:09: [AMXX] Displaying debug trace (plugin "ncod_class_cybersuit.amxx")
L 10/24/2016 - 22:49:09: [AMXX] Run time error 10: native error (native "ncod_setUserStatist")
L 10/24/2016 - 22:49:09: [AMXX]    [0] ncod_class_cybersuit.sma::ncod_classChangeState (line 53)
Why? Please help me.
Attached Files
File Type: inc ncodmod.inc (4.7 KB, 160 views)
File Type: sma Get Plugin or Get Source (NewCodMod_Engine.sma - 703 views - 43.7 KB)
BeNq! is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-24-2016 , 17:40   Re: Run time error 4: index out of bounds
Reply With Quote #2

Its common error happens due passing index into native which the passed index is not in bound
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-24-2016 , 18:17   Re: Run time error 4: index out of bounds
Reply With Quote #3

How to fix?
BeNq! is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-25-2016 , 09:16   Re: Run time error 4: index out of bounds
Reply With Quote #4

Please help me.
BeNq! is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-26-2016 , 13:57   Re: Run time error 4: index out of bounds
Reply With Quote #5

Where is bug? Run time error 4: index out of bounds.
BeNq! is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-26-2016 , 18:56   Re: Run time error 4: index out of bounds
Reply With Quote #6

Code:

Code:
// ncod_getUserStats( id, NCodStatist: iStatist )
public nativeGetUserStatist( iPlugin, iParams )
{
	if( iParams != 2 )
	{
		new szPlugin[ 2 ][ 64 ];
		get_plugin( iPlugin, szPlugin[ 0 ], 63, szPlugin[ 1 ], 63 );
		
		log_amx( "[ %s < %s > ]: Blad przy pobieraniu wartosci statystyki!", szPlugin[ 1 ], szPlugin[ 0 ] );
		return -1;
	}
	
	return gPlayerInfo[ get_param( 1 ) ][ playerInfo: giStatistics[ NCodStatist: get_param( 2 ) ] ];
}

// ncod_setUserStats( id, NCodStatist: iStatist, iValue )
public nativeSetUserStatist( iPlugin, iParams )
{
	if( iParams != 3 )
	{
		new szPlugin[ 2 ][ 64 ];
		get_plugin( iPlugin, szPlugin[ 0 ], 63, szPlugin[ 1 ], 63 );
		
		log_amx( "[ %s < %s > ]: Blad przy pobieraniu wartosci statystyki!", szPlugin[ 1 ], szPlugin[ 0 ] );
		return -1;
	}
	
	if( any: get_param( 2 ) != NCODSTATIST_LEVEL )
		gPlayerInfo[ get_param( 1 ) ][ playerInfo: giStatistics[ NCodStatist: get_param( 2 ) ] ] = get_param( 3 );
	else
	{
		gPlayerInfo[ get_param( 1 ) ][ playerInfo: giStatistics[ NCODSTATIST_EXPERIENCE ] ] = power( get_param( 3 ), 2 ) * gPluginInfo[ plExperienceMultiplier ];
		gPlayerInfo[ get_param( 1 ) ][ playerInfo: giStatistics[ NCODSTATIST_LEVEL ] ] = get_param( 3 );
	}
	
	return 0;
}
Error with:
Code:
gPlayerInfo[ get_param( 1 ) ][ playerInfo: giStatistics[ NCodStatist: get_param( 2 ) ] ] = get_param( 3 );
Code:
return gPlayerInfo[ get_param( 1 ) ][ playerInfo: giStatistics[ NCodStatist: get_param( 2 ) ] ];

Last edited by BeNq!; 10-26-2016 at 18:56.
BeNq! is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-26-2016 , 19:47   Re: Run time error 4: index out of bounds
Reply With Quote #7

Edited to eliminate warnings in 1.8.2:
PHP Code:
// ncod_getUserStats( id, NCodStatist: iStatist )
public nativeGetUserStatistiPluginiParams )
{
    new 
iParam1 get_param);
    new 
iParam2 get_param);
    new 
szPlugin][ 64 ];
    
    if( 
iParams != )
    {
        
get_pluginiPluginszPlugin], 63szPlugin], 63 );
        
log_amx"[ %s < %s > ]: Blad przy pobieraniu wartosci statystyki!"szPlugin], szPlugin] );
        return -
1;
    }
    else if ( ( 
iParam1 >= sizeofgPlayerInfo ) ) || ( iParam2 >= sizeofgiStatistics ) ) || ( giStatisticsiParam2 ] >= sizeofgPlayerInfo[] ) ) )
    {
        
get_pluginiPluginszPlugin], 63szPlugin], 63 );
        
log_amx"[ %s < %s > ]: Bad param values!"szPlugin], szPlugin] );
        return -
1;    
    }
        
    return 
gPlayerInfoiParam1 ][ playerInfogiStatisticsiParam2 ] ];
}

// ncod_setUserStats( id, NCodStatist: iStatist, iValue )
public nativeSetUserStatistiPluginiParams )
{
    new 
iParam1 get_param);
    new 
iParam2 get_param);
    new 
szPlugin][ 64 ];
    
    if( 
iParams != )
    {
        
get_pluginiPluginszPlugin], 63szPlugin], 63 );
        
log_amx"[ %s < %s > ]: Blad przy pobieraniu wartosci statystyki!"szPlugin], szPlugin] );
        return -
1;
    }
    else if ( ( 
iParam1 >= sizeofgPlayerInfo ) ) || ( iParam2 >= sizeofgiStatistics ) ) || ( giStatisticsiParam2 ] >= sizeofgPlayerInfo[] ) ) )
    {
        
get_pluginiPluginszPlugin], 63szPlugin], 63 );
        
log_amx"[ %s < %s > ]: Bad param values!"szPlugin], szPlugin] );
        return -
1;    
    }

    if( 
anyget_param) != NCODSTATIST_LEVEL )
    {
        
gPlayerInfoiParam1 ][ playerInfogiStatisticsiParam2 ] ] = get_param);
    }
    else
    {
        
gPlayerInfoiParam1 ][ playerInfogiStatisticsNCODSTATIST_EXPERIENCE ] ] = powerget_param), ) * gPluginInfoplExperienceMultiplier ];
        
gPlayerInfoiParam1 ][ playerInfogiStatisticsNCODSTATIST_LEVEL ] ] = get_param);
    }
    
    return 
0;

__________________

Last edited by Bugsy; 11-05-2016 at 11:27.
Bugsy is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-27-2016 , 19:27   Re: Run time error 4: index out of bounds
Reply With Quote #8

"Tag mismatch":

Code:
 else if ( ( iParam1 >= sizeof( gPlayerInfo ) ) || ( iParam2 >= sizeof( giStatistics ) ) || ( giStatistics[ iParam2 ] >= sizeof( gPlayerInfo[] ) ) )
Code:
else if ( ( iParam1 >= sizeof( gPlayerInfo ) ) || ( iParam2 >= sizeof( giStatistics ) ) || ( giStatistics[ iParam2 ] >= sizeof( gPlayerInfo[] ) ) )
BeNq! is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-27-2016 , 19:40   Re: Run time error 4: index out of bounds
Reply With Quote #9

Try this
PHP Code:
else if ( ( iParam1 >= sizeofgPlayerInfo ) ) || ( iParam2 >= sizeofgiStatistics ) ) || ( _:giStatisticsiParam2 ] >= sizeofgPlayerInfo[] ) ) ) 
__________________

Last edited by Bugsy; 10-27-2016 at 19:42.
Bugsy is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-03-2016 , 08:24   Re: Run time error 4: index out of bounds
Reply With Quote #10

Nope, "Tag mistmatch".
BeNq! 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 04:11.


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