SA-MP Forums Archive
Accessing element at negative index -400 - 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: Accessing element at negative index -400 (/showthread.php?tid=369669)



Accessing element at negative index -400 - Vvolk - 17.08.2012

Hello everybody! Today I put crashdetect.dll plugin to my server to check errors. And I get this error in server-log file:

Код:
[22:24:35] [debug] Run time error 4: "Array index out of bounds"
[22:24:35] [debug]  Accessing element at negative index -400
[22:24:35] [debug] AMX backtrace:
[22:24:35] [debug] #0 0000cff4 in ?? () from SAMP.amx
[22:24:35] [debug] #1 001bb3d8 in public Kuro () from SAMP.amx
This happens in this code, because if I coment this callback called "Kuro" I don't see errors. Take that code:


Код:
new Float:TrDegalai[MAX_VEHICLES];//In top of my gm.

forward Kuro();
public Kuro()
{
	for(new vehicleid=0; vehicleid<MAX_VEHICLES; vehicleid++)
	{
		printf("Vehicleid %d",vehicleid);
		if(ArNaudojaDegalus(vehicleid))
		{
			if(GetVehicleBakas(vehicleid) >= 30 && GetVehicleBakas(vehicleid) <= 200)
			{
				switch(random(10))
				{
					case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-20;
					case 1: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-18;
					case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-14;
					case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-2;
					case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-10;
					case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-15;
					case 6:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-16;
					case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-7;
					case 8:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-5;
					case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-11;
				}
			}
			else if(GetVehicleBakas(vehicleid) > 200 && GetVehicleBakas(vehicleid) <= 2000)
			{
				switch(random(10))
				{
					case 0:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-150;
					case 1:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-100;
					case 2:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-89;
					case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-20;
					case 4:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-28;
					case 5:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-40;
					case 6:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-120;
					case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-169;
					case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-57;
					case 9:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-66;
				}
			}
			else if(GetVehicleBakas(vehicleid) > 2000)
			{
				switch(random(10))
				{
					case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-800;
					case 1:	TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-950;
					case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-156;
					case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-789;
					case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-500;
					case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-658;
					case 6: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-123;
					case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-169;
					case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-57;
					case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-648;
				}
			}
			else if(GetVehicleBakas(vehicleid) < 30)
			{
				switch(random(10))
				{
					case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-4;
					case 1: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-5;
					case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-1;
					case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-2;
					case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-3;
					case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-1;
					case 6: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-4;
					case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-3;
					case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-2;
					case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-1;
				}
			}
		}
	}
	return 1;
}
Can anyone say there is the problem, because I can't find it here.


Re: Accessing element at negative index -400 - liinor - 29.10.2012

new model = (GetVehicleModel(vehicleid))-400;

Some this kind of code somewhere in your script.


Re: Accessing element at negative index -400 - Vince - 29.10.2012

For goodness' sake, please use only English names in your code! How are we supposed to know what "ArNaudojaDegalus" means?!