SA-MP Forums Archive
[debug] Run time error 4: "Array index out of bounds" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [debug] Run time error 4: "Array index out of bounds" (/showthread.php?tid=611343)



[debug] Run time error 4: "Array index out of bounds" - Hanga - 05.07.2016

Hello guys, i have a problem
when I start server ( host or localhost ) I give that error:

( In localhost )
Код:
[debug] Run time error 4: "Array index out of bounds"
[debug] AMX backtrace:
[debug] #0 000f9fe8 in public LoadGraffiti () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:15464
[debug] #1 000faec4 in public LoadClans () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:15500
[debug] #2 001c5d98 in public PHY_OnGameModeInit () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:19100
[debug] #3 native CallLocalFunction () from samp-server.exe
[debug] #4 0003e4e0 in public ScriptInit_OnGameModeInit ()  at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\physics.inc:173
[debug] #5 00002e98 in public GZ_OnGameModeInit () at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\YSI_Data\..\YSI_Internal\..\YSI_Core\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:184
[debug] #6 00000844 in public OnPlayerDeath (playerid=0, killerid=0, reason=0) at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\gangzone:125
( In host )

Код:
[debug] Run time error 4: "Array index out of bounds"
[debug] AMX backtrace:
[debug] #0 000f9fe8 in public LoadGraffiti () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:15464
[debug] #1 000faec4 in public LoadClans () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:15500
[debug] #2 001c5d98 in public PHY_OnGameModeInit () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:19100
[debug] #3 native CallLocalFunction () from samp03svr
[debug] #4 0003e4e0 in public ScriptInit_OnGameModeInit ()  at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\physics.inc:173
[debug] #5 00002e98 in public GZ_OnGameModeInit () at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\YSI_Data\..\YSI_Internal\..\YSI_Core\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:184
[debug] #6 00000844 in public OnPlayerDeath (playerid=0, killerid=0, reason=0) at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\gangzone:125
[debug] #0 000f9fe8 in public LoadGraffiti () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:15464
[debug] #1 000faec4 in public LoadClans () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:15500

Код:
forward LoadGraffiti();
public LoadGraffiti()
{
	new Cache: Result = mysql_query(mysql, "SELECT * FROM `graffiti` ORDER BY `graffiti`.`ID` ASC");
	new graff = 0, x, result[256], tagname[1000];
 	for(new i, j = cache_get_row_count (); i != j; ++i)
	{
	    graff ++;
       	cache_get_field_content(i, "ID", result); x = strval(result); GraffitiInfo[x][gfID] = x; //that is line 15464
       	cache_get_field_content(i, "X", result); GraffitiInfo[x][gfX] = floatstr(result);
       	cache_get_field_content(i, "Y", result); GraffitiInfo[x][gfY] = floatstr(result);
     	cache_get_field_content(i, "Z", result); GraffitiInfo[x][gfZ] = floatstr(result);
      	cache_get_field_content(i, "Rot", result); GraffitiInfo[x][gfRot] = floatstr(result);
       	cache_get_field_content(i, "Owned", result); GraffitiInfo[x][gfOwned] = strval(result);

	    GraffitiInfo[x][gfObject] = CreateDynamicObject(19373, GraffitiInfo[x][gfX], GraffitiInfo[x][gfY], GraffitiInfo[x][gfZ], 0.0, 0.0, GraffitiInfo[x][gfRot]);
	    //GraffitiInfo[x][gfObject] = CreateDynamicObject(19482, GraffitiInfo[x][gfX], GraffitiInfo[x][gfY], GraffitiInfo[x][gfZ], 0.0, 0.0, GraffitiInfo[x][gfRot]);
	    if(GraffitiInfo[x][gfOwned] == 0 ) tagname = "None";
	    else format(tagname, sizeof(tagname), "{%s}%s \n %s", ClanInfo[GraffitiInfo[x][gfOwned]][Color], ClanInfo[GraffitiInfo[x][gfOwned]][Name] ,ClanInfo[GraffitiInfo[x][gfOwned]][Tag]);
	    SetDynamicObjectMaterialText(GraffitiInfo[x][gfObject], 0, tagname, OBJECT_MATERIAL_SIZE_512x512, "BankGothic Md BT", 60, 1, 0xfff0f0f0, 0, 1);
	}
	printf("[Graffiti Script]: %d graffiti loaded.", graff);
	cache_delete(Result);
	return 1;
}

function LoadClans()
{
	new Cache: Result = mysql_query( mysql, "SELECT * FROM `groups`" ), Get[ 2 ];
	cache_get_data( Get[ 0 ], Get[ 1 ], SQL ); // Get[ 0 ] - Rows || Get[ 1 ] - Fields || SQL - connectionHandle
    for(new i = 0; i < Get[0]; i++)
    {
  		new id =  cache_get_field_content_int( i, "ID", mysql );
		cache_get_field_content( i, "Owner", ClanInfo[id][Owner], mysql, 80 );
		cache_get_field_content( i, "Name", ClanInfo[id][Name], mysql, 80 );
		cache_get_field_content( i, "TAG", ClanInfo[id][Tag], mysql, 80 );

		ClanInfo[id][Valid] = 1;
		format(ClanInfo[id][Color], 256, "ff6f69");
	    sClans ++;
	}

 	cache_delete( Result );
	tabele ++;
	LoadGraffiti(); //that is line 15500

}
[debug] #2 001c5d98 in public PHY_OnGameModeInit () at C:\Users\Acasa\Desktop\Gamemode SA-MP\gamemodes\zuzu.pwn:19100

Код:
public OnGameModeInit()
{

	//SetServerMaxPlayers(100); // o sa fie setati maxim 100 jucatori.
 	//SetTimer("AnimatieBasculanta", 5000, 1);
	AntiDeAMX();
	MysqlData();
	IncarcaStatistica();
	IncarcaDestinatiiTrucker();

	LoadBizz();
	GoldEvent = 1;
	JobEvent = 1;
	ActualizareVreme();
	LoadSBizz();
	IncarcaTextdraws();
	IncarcaMappingServer();
	LoadHouses();

	if(FootballTeren == 1){		CreateBall();	}
	LoadCollisions();
	LoadStadion();

	AranjareCeas();
	AllowInteriorWeapons(0);
	DisableInteriorEnterExits();
	LoadClans();
	EnableStuntBonusForAll(0); //that is line 19100
     //the rest of script ...
[debug] #5 00002e98 in public GZ_OnGameModeInit () at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\YSI_Data\..\YSI_Internal\..\YSI_C ore\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc :184

Код:
public OnGameModeInit()
{
	state _ALS : _ALS_go;
	if (!YSI_FILTERSCRIPT)
	{
		state _script_init_fix_state : false;
		#if defined ScriptInit_OnScriptInit
			ScriptInit_OnScriptInit();
		#endif
		#if defined YSI_LOCK_MODE
			if (YSI_gLockData[
				floatround(floatlog(_LOCK_LEN_0 + 1), floatround_ceil) + 1 +
				floatround(floatlog(_LOCK_LEN_1 + 1), floatround_ceil) + 1 +
				floatround(floatlog(_LOCK_LEN_2 + 1), floatround_ceil) +
				floatround(floatlog(_LOCK_LEN_3 + 1), floatround_ceil)] == '\0'
			 || YSI_gLockData[
				floatround(floatlog(_LOCK_LEN_0 + 1), floatround_ceil) + 1 +
				floatround(floatlog(_LOCK_LEN_1 + 1), floatround_ceil) + 1 +
				floatround(floatlog(_LOCK_LEN_2 + 1), floatround_ceil) + 1 +
				floatround(floatlog(_LOCK_LEN_3 + 1), floatround_ceil) + 1] == '\0')
			{
				y_lock 8;
			}
		#endif
	}
	ScriptInit_OnGameModeInit();
	return 1; //that is line 184
}
[debug] #6 00000844 in public OnPlayerDeath (playerid=0, killerid=0, reason=0) at C:\Users\Acasa\Desktop\Gamemode SA-MP\pawno\include\gangzone:125


Код:
#else// if used in a gamemode

	public OnGameModeInit()
	{
	    DestroyAllGangZones();//destory all gangzones

	    #if defined GZ_OnGameModeInit
			GZ_OnGameModeInit();
		#endif
		return 1; //that is line 125
	}
	#if defined _ALS_OnGameModeInit
		#undef OnGameModeInit
	#else
		#define _ALS_OnGameModeInit
	#endif
	#define OnGameModeInit GZ_OnGameModeInit
	#if defined GZ_OnGameModeInit
		forward GZ_OnGameModeInit();
	#endif

	public OnGameModeExit()
	{
	    DestroyAllGangZones();//destory all gangzones

	    #if defined GZ_OnGameModeExit
			GZ_OnGameModeExit();
		#endif
		return 1;
	}
	#if defined _ALS_OnGameModeExit
		#undef OnGameModeExit
	#else
		#define _ALS_OnGameModeExit
	#endif
	#define OnGameModeExit GZ_OnGameModeExit
	#if defined GZ_OnGameModeExit
		forward GZ_OnGameModeExit();
	#endif

#endif
Plz help me
I can say that this problem appeared suddenly, I run my GM well when suddenly this error occurred, the error occurs on any version of GM would run (as I have back-up)
Sorry for my bad english skills..


Re: [debug] Run time error 4: "Array index out of bounds" - Vince - 05.07.2016

The array index should be i, not x.


Re: [debug] Run time error 4: "Array index out of bounds" - Hanga - 05.07.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
The array index should be i, not x.
Where?


Re: [debug] Run time error 4: "Array index out of bounds" - Mencent - 05.07.2016

Hello!

Try this:
PHP код:
forward LoadGraffiti();
public 
LoadGraffiti()
{
    new 
CacheResult mysql_query(mysql"SELECT * FROM `graffiti` ORDER BY `graffiti`.`ID` ASC");
    new 
graff 0xresult[256], tagname[1000];
     for(new 
icache_get_row_count (); != j; ++i)
    {
        
graff ++;
           
cache_get_field_content(i"ID"result); strval(result); GraffitiInfo[i][gfID] = x//that is line 15464
           
cache_get_field_content(i"X"result); GraffitiInfo[i][gfX] = floatstr(result);
           
cache_get_field_content(i"Y"result); GraffitiInfo[i][gfY] = floatstr(result);
         
cache_get_field_content(i"Z"result); GraffitiInfo[i][gfZ] = floatstr(result);
          
cache_get_field_content(i"Rot"result); GraffitiInfo[i][gfRot] = floatstr(result);
           
cache_get_field_content(i"Owned"result); GraffitiInfo[i][gfOwned] = strval(result);
        
GraffitiInfo[i][gfObject] = CreateDynamicObject(19373GraffitiInfo[i][gfX], GraffitiInfo[i][gfY], GraffitiInfo[i][gfZ], 0.00.0GraffitiInfo[i][gfRot]);
        
//GraffitiInfo[i][gfObject] = CreateDynamicObject(19482, GraffitiInfo[i][gfX], GraffitiInfo[i][gfY], GraffitiInfo[i][gfZ], 0.0, 0.0, GraffitiInfo[i][gfRot]);
        
if(GraffitiInfo[i][gfOwned] == tagname "None";
        else 
format(tagnamesizeof(tagname), "{%s}%s \n %s"ClanInfo[GraffitiInfo[i][gfOwned]][Color], ClanInfo[GraffitiInfo[i][gfOwned]][Name] ,ClanInfo[GraffitiInfo[i][gfOwned]][Tag]);
        
SetDynamicObjectMaterialText(GraffitiInfo[i][gfObject], 0tagnameOBJECT_MATERIAL_SIZE_512x512"BankGothic Md BT"6010xfff0f0f001);
    }
    
printf("[Graffiti Script]: %d graffiti loaded."graff);
    
cache_delete(Result);
    return 
1;




Re: [debug] Run time error 4: "Array index out of bounds" - Hanga - 05.07.2016

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Try this:
PHP код:
forward LoadGraffiti();
public 
LoadGraffiti()
{
    new 
CacheResult mysql_query(mysql"SELECT * FROM `graffiti` ORDER BY `graffiti`.`ID` ASC");
    new 
graff 0xresult[256], tagname[1000];
     for(new 
icache_get_row_count (); != j; ++i)
    {
        
graff ++;
           
cache_get_field_content(i"ID"result); strval(result); GraffitiInfo[i][gfID] = x//that is line 15464
           
cache_get_field_content(i"X"result); GraffitiInfo[i][gfX] = floatstr(result);
           
cache_get_field_content(i"Y"result); GraffitiInfo[i][gfY] = floatstr(result);
         
cache_get_field_content(i"Z"result); GraffitiInfo[i][gfZ] = floatstr(result);
          
cache_get_field_content(i"Rot"result); GraffitiInfo[i][gfRot] = floatstr(result);
           
cache_get_field_content(i"Owned"result); GraffitiInfo[i][gfOwned] = strval(result);
        
GraffitiInfo[i][gfObject] = CreateDynamicObject(19373GraffitiInfo[i][gfX], GraffitiInfo[i][gfY], GraffitiInfo[i][gfZ], 0.00.0GraffitiInfo[i][gfRot]);
        
//GraffitiInfo[i][gfObject] = CreateDynamicObject(19482, GraffitiInfo[i][gfX], GraffitiInfo[i][gfY], GraffitiInfo[i][gfZ], 0.0, 0.0, GraffitiInfo[i][gfRot]);
        
if(GraffitiInfo[i][gfOwned] == tagname "None";
        else 
format(tagnamesizeof(tagname), "{%s}%s \n %s"ClanInfo[GraffitiInfo[i][gfOwned]][Color], ClanInfo[GraffitiInfo[i][gfOwned]][Name] ,ClanInfo[GraffitiInfo[i][gfOwned]][Tag]);
        
SetDynamicObjectMaterialText(GraffitiInfo[i][gfObject], 0tagnameOBJECT_MATERIAL_SIZE_512x512"BankGothic Md BT"6010xfff0f0f001);
    }
    
printf("[Graffiti Script]: %d graffiti loaded."graff);
    
cache_delete(Result);
    return 
1;

Thx, now working, but can you tell me what was wrong?


Re: [debug] Run time error 4: "Array index out of bounds" - Mencent - 05.07.2016

Yes, of course.

You used "x" instead of "i".
But the "x" include only the value of the "id" and the "i" is the index.
I hope you understand what I mean.


Re: [debug] Run time error 4: "Array index out of bounds" - Hanga - 05.07.2016

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Yes, of course.

You used "x" instead of "i".
But the "x" include only the value of the "id" and the "i" is the index.
I hope you understand what I mean.
I understand, thx for help :3
REP +