Raised This Month: $ Target: $400
 0% 

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-26-2016 , 18:56   Re: Run time error 4: index out of bounds
Reply With Quote #1

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 #2

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
Reply



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 09:10.


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