Raised This Month: $51 Target: $400
 12% 

Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-06-2016 , 11:20   Re: Run time error 4: index out of bounds
Reply With Quote #21

You are not using the code I gave you (nativeGetUserStatist,nativeSetUserStatist), and you have _: in the include which I told you to remove.

While this fix will eliminate an index out of bounds error, the functionality will not be as intended by the mod author. Can you show me your plugin code? I think this is where the issue lies, not in the mod/include.

Quote:
Originally Posted by Bugsy View Post
:Shrug:

Did you add any '_:' to the include? If so, remove them.
Code:
#if defined _ncodmod_included
  #endinput
#endif
#define _ncodmod_included

enum NCodState {
	NCODSTATE_DISABLE,
	NCODSTATE_ENABLE,
	NCODSTATE_USE,
	NCODSTATE_SPAWN
}

enum _:NCodStatist
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-06-2016 at 12:13.
Bugsy is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-06-2016 , 15:23   Re: Run time error 4: index out of bounds
Reply With Quote #22

This mod is a kind of DiabloMod. Class, perks ( items ) etc.

Plugin: https://forums.alliedmods.net/showpo...8&postcount=16

ncod_setUserStatist(id, NCODSTATIST_HEALTH, 20)
BeNq! is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 11-06-2016 , 16:51   Re: Run time error 4: index out of bounds
Reply With Quote #23

Quote:
Originally Posted by Bugsy View Post
It basically allows you to tag the enum for array sizing purposes but the type/tag checking is not enforced in code.

PHP Code:
#include <amxmodx>

enum Test
{
    
Item1,
    
Item2,
    
Item355 ]
}

new 
tTestTest ];

public 
TestFunc() 
{
    
//Works fine with or without _: since the array was sized with Test and expects one of the enumerators (Item1,Item2,Item3)
    
tTestItem2 ] = 25;
    
    
//Will give a warning without _: because it expects only Item1, Item2, or Item3 passed in the array. The code will still work
    //perfectly since Item2 = 1.
    
tTest] = 25;
    
    
//You can 'type-cast' a value like this to eliminate a warning. These will give warnings if you use _: on the enum
    //because you are telling it to not enforce tag checking yet you are trying to use tagging.
    
tTestTest:] = 25;
    
    new 
iVal 1;
    
tTestTest:iVal ] = 25;

I completly understand.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-06-2016 , 18:33   Re: Run time error 4: index out of bounds
Reply With Quote #24

Quote:
Originally Posted by BeNq! View Post
This mod is a kind of DiabloMod. Class, perks ( items ) etc.

Plugin: https://forums.alliedmods.net/showpo...8&postcount=16

ncod_setUserStatist(id, NCODSTATIST_HEALTH, 20)
I need to see what calls ncod_classChangeState() since this is the only function that calls ncod_setUserStatist() in the plugin you linked me to.
__________________
Bugsy is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-07-2016 , 10:24   Re: Run time error 4: index out of bounds
Reply With Quote #25

E.g.

1#
Code:
public client_disconnect( id )
{
	if( is_user_bot( id ) ) return;

	if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] != -1 )
	{
		new classBuffer[ classInfo ];
	
		ArraySetArray( gPlayerInfo[ id ][ piClasses ], gPlayerInfo[ id ][ piClass ][ pciIdentificator ], gPlayerInfo[ id ][ piClass ] );
		ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
		
		new iForward, iRet;
		iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
		ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_DISABLE )
		DestroyForward( iForward );
		
		gPlayerInfo[ id ][ piClass ][ pciIdentificator ] = -1;
	}
	
	if( gPlayerInfo[ id ][ piPerk ] != -1 )
	{
		new perkBuffer[ itemInfo ];
	
		ArrayGetArray( gaPerks, gPlayerInfo[ id ][ piPerk ], perkBuffer );
		
		new iForward, iRet;
		iForward = CreateOneForward( perkBuffer[ iiPlugin ], "ncod_perkChangeState", FP_CELL, FP_CELL, FP_CELL );
		ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piPerk ], NCODSTATE_DISABLE )
		DestroyForward( iForward );
		
		gPlayerInfo[ id ][ piPerk ] = -1;
		gPlayerInfo[ id ][ piPerkDurability ] = 0;
	}

	savePlayer( id );
}
2#
Code:
public eventChangeTeam( )
{
	static iOldTeam[ 33 ];
	new id = read_data( 1 );
	
	if( is_user_bot( id ) || iOldTeam[ id ] == get_user_team( id ) )
		return;
	
	new classBuffer[ classInfo ];

	if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] != -1 )
	{
		ArraySetArray( gPlayerInfo[ id ][ piClasses ], gPlayerInfo[ id ][ piClass ][ pciIdentificator ], gPlayerInfo[ id ][ piClass ] );
		ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
		
		new iForward, iRet;
		iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
		ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_DISABLE )
		DestroyForward( iForward );
	}
	
	gPlayerInfo[ id ][ piClass ] = { -1, 0, 0, 0, 0, 0, 0, 0, 0 };
	gPlayerInfo[ id ][ piMenuFirstTime ] = true;
	
	format( gPlayerBuffer[ id ][ cInfo ][ ciName ], 127, "Brak" );
	gPlayerBuffer[ id ][ bLastC ] = -1;
	
	iOldTeam[ id ] = get_user_team( id );
}
3#
Code:
public fwEmitSound( id, iChannel, szSound[], Float: fVol, Float: fAttn, iFlags, iPitch ) 
{
	if( !is_user_alive( id ) )
		return FMRES_IGNORED;
		
	if( strfind( szSound, "wpn_denyselect.wav" ) != -1 )
	{
		if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] == -1 )
			return FMRES_IGNORED;
		
		new classBuffer[ classInfo ];
		ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
	
		new iRet, iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
		ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_USE );
		DestroyForward( iForward );
		
		return FMRES_SUPERCEDE;
	}

	return FMRES_IGNORED;
}
4#
Code:
public setPlayerAbilities( id )
{
	set_pev( id, pev_health, 100.0 + float( gPlayerInfo[ id ][ piClass ][ pciHealth ] ) );
	
	new classBuffer[ classInfo ];
	ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
	
	new bool:bC4 = false, szWeapon[ 64 ];
	if( pev( id, pev_weapons ) & CSW_C4 ) bC4 = true;
	
	fm_strip_user_weapons( id );
	fm_give_item( id, "weapon_knife" );
	
	for( new i = 1; i < 33; i ++ )
	{
		if( !( classBuffer[ ciWeapons ] & ( 1 << i ) ) )
			continue;
			
		get_weaponname( i, szWeapon, 63 );
		fm_give_item( id, szWeapon );
		fm_give_item( id, szWeapon );
		fm_give_item( id, szWeapon );
		fm_give_item( id, szWeapon );
	}
	
	if( bC4 ) fm_give_item( id, "weapon_c4" );
	
	new iRet, iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
	ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_SPAWN );
	DestroyForward( iForward );
}
5#
Code:
public cmdClassH( id, iMenu, iItem )
{
	client_cmd( id, "spk %s", gszPluginSounds[ psSelectMenuItem ] );

	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, iCallback, iClassID, iForward;
	new szClassID[ 5 ], szName[ 33 ];
	
	menu_item_getinfo( iMenu, iItem, iAccess, szClassID, 4, szName, 32, iCallback );
	iClassID = str_to_num( szClassID );
	
	new classBuffer[ classInfo ];
	new iRet;
	
	if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] != -1 )
	{
		ArraySetArray( gPlayerInfo[ id ][ piClasses ], gPlayerInfo[ id ][ piClass ][ pciIdentificator ], gPlayerInfo[ id ][ piClass ] );
		ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
		
		iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
		ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_DISABLE )
		DestroyForward( iForward );
	}
	
	ArrayGetArray( gaClasses, iClassID, classBuffer );
	
	if( classBuffer[ ciAccessFlags ] != 0 && !( get_user_flags( id ) & classBuffer[ ciAccessFlags ] ) )
	{	
		printInformation( id, NCODINFOTYPE_CHAT, NCODINFOCOLOR_NORMAL, "Nie masz dostepu do tej klasy." )
		cmdClass( id )
		
		return PLUGIN_HANDLED
	}
	
	ArrayGetArray( gPlayerInfo[ id ][ piClasses ], iClassID, gPlayerInfo[ id ][ piClass ] );
	
	iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
	ExecuteForward( iForward, iRet, id, iClassID, NCODSTATE_ENABLE )
	DestroyForward( iForward );
	
	checkPlayerLevel( id );
	
	if( gPlayerInfo[ id ][ piMenuFirstTime ] )
	{
		setPlayerAbilities( id )
		gPlayerInfo[ id ][ piMenuFirstTime ] = false;
	}
	
	return PLUGIN_HANDLED
}
Full .sma in attachment: https://forums.alliedmods.net/showpo...75&postcount=1
BeNq! is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-09-2016 , 07:11   Re: Run time error 4: index out of bounds
Reply With Quote #26

Bugsy? You need anything else?
BeNq! is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-09-2016 , 19:24   Re: Run time error 4: index out of bounds
Reply With Quote #27

Quote:
Originally Posted by BeNq! View Post
Bugsy? You need anything else?
Sorry but I do not have time to reverse engineer the code and figure out why it is broken. Have you asked the author about your issue?
__________________
Bugsy is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-10-2016 , 08:56   Re: Run time error 4: index out of bounds
Reply With Quote #28

The author isn't responsible.
BeNq! 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 18:34.


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