SA-MP Forums Archive
Array error - 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: Array error (/showthread.php?tid=559491)



Array error - IndependentGaming - 23.01.2015

Greetings i made someting dynamic but it give me this error when i start the server
Код:
[18:11:11] [debug] Run time error 4: "Array index out of bounds"
[18:11:11] [debug]  Accessing element at index 20 past array upper bound 19
[18:11:11] [debug] AMX backtrace:
[18:11:11] [debug] #0 000c9ee4 in public OnLoadViplockerPoints () from DCRP.amx
[18:11:11] [LoadDynamicDoors] 2000 doors rehashed/loaded.
[18:11:11] [LoadDynamicMapIcons] 1 map icons rehashed/loaded.
[18:11:11] [LoadDynamicTexts] 1000 Texts Labels rehashed/loaded.
in the gamemode i have no errors

thanks in advance


Re: Array error - ATGOggy - 23.01.2015

Show OnLoadViplocker()


Re: Array error - Luca12 - 23.01.2015

Post here your public OnLoadViplockerPoints ()


Re: Array error - IndependentGaming - 23.01.2015

Код:
forward OnLoadViplockerPoints();
public OnLoadViplockerPoints()
{
	new i, rows, fields, tmp[128], string[128];
	cache_get_data(rows, fields, MainPipeline);

	while(i < rows)
	{
		cache_get_field_content(i, "id", tmp, MainPipeline);  ViplockerPoints[i][viplockerSQLId] = strval(tmp);
		cache_get_field_content(i, "PosX", tmp, MainPipeline); ViplockerPoints[i][viplockerPosX] = floatstr(tmp);
		cache_get_field_content(i, "PosY", tmp, MainPipeline); ViplockerPoints[i][viplockerPosY] = floatstr(tmp);
		cache_get_field_content(i, "PosZ", tmp, MainPipeline); ViplockerPoints[i][viplockerPosZ] = floatstr(tmp);
		cache_get_field_content(i, "VW", tmp, MainPipeline); ViplockerPoints[i][viplockerVW] = strval(tmp);
		cache_get_field_content(i, "Int", tmp, MainPipeline); ViplockerPoints[i][viplockerInt] = strval(tmp);
		if(ViplockerPoints[i][viplockerPosX] != 0)
		{
			format(string, sizeof(string), "Vip Locker #%d\nType /viplocker to open it.", i);
			ViplockerPoints[i][viplockerTextID] = CreateDynamic3DTextLabel(string, COLOR_PURPLE, ViplockerPoints[i][viplockerPosX], ViplockerPoints[i][viplockerPosY], ViplockerPoints[i][viplockerPosZ]+0.6, 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ViplockerPoints[i][viplockerVW], ViplockerPoints[i][viplockerInt], -1);
		}
		i++;
	}
}



Re: Array error - Jay_ - 23.01.2015

Just because there are no errors when compiling doesn't necessarily suggest that there will not be any errors during runtime. The PAWN compiler is extremely dumb compared to most modern compilers.

As the error suggests one of your array indexes are out of bounds. Judging by the code you have provided this is most likely present in the ViplockerPoints array. You need to do some research as to what this means as you are likely to experience this often. Search these forums as the questions has been answered many times before.


Re: Array error - IndependentGaming - 23.01.2015

Quote:
Originally Posted by Jay_
Посмотреть сообщение
Just because there are no errors when compiling doesn't necessarily suggest that there will not be any errors during runtime. The PAWN compiler is extremely dumb compared to most modern compilers.

As the error suggests one of your array indexes are out of bounds. Judging by the code you have provided this is most likely present in the ViplockerPoints array. You need to do some research as to what this means as you are likely to experience this often. Search these forums as the questions has been answered many times before.
can it be in the mysql database ?


Re: Array error - IndependentGaming - 23.01.2015

Problem has been solved

Thanks to Jay_