SA-MP Forums Archive
Error debug - 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: Error debug (/showthread.php?tid=511947)



Error debug - [RO]Five - 08.05.2014

Error:
Код:
[12:20:36] [debug] Run time error 4: "Array index out of bounds"
[12:20:36] [debug]  Accessing element at index 15 past array upper bound 14
[12:20:36] [debug] AMX backtrace:
[12:20:36] [debug] #0 000c8ba0 in public LTeri () at C:\~Jocuri~\Trucking samp\gamemodes\v3.4.pwn:12262
Script:
Код:
public LTeri()
{
	new Rows, Fields, t=0, ax=0, nrt;
	cache_get_data(Rows, Fields, mysql);
	if(Rows)
	{
		for(; t != Rows; ++t, ax = 0)
		{
			if ( t >= 29 ) {
				printf( " !ERROR! Numarul de teritorii depaseste numarul maxim !ERROR!" ) ;
				break ;
			}

			TeritoriuInfo[t][tID]		= cache_get_row_int(t, ax++, mysql) ; // Line 12262
			cache_get_row(t, ax++, TeritoriuInfo[t][tOwner], mysql, MAX_PLAYER_NAME) ;
			TeritoriuInfo[t][tOwned]	= cache_get_row_int(t, ax++, mysql) ;
			TeritoriuInfo[t][tTime]	= cache_get_row_int(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozX1] 	= cache_get_row_float(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozY1] 	= cache_get_row_float(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozX2] 	= cache_get_row_float(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozY2] 	= cache_get_row_float(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozX3] 	= cache_get_row_float(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozY3] 	= cache_get_row_float(t, ax++, mysql) ;
			TeritoriuInfo[t][tPozZ3] 	= cache_get_row_float(t, ax++, mysql) ;
			turf[t] = GangZoneCreateEx(TeritoriuInfo[t][tPozX1], TeritoriuInfo[t][tPozY1], TeritoriuInfo[t][tPozX2], TeritoriuInfo[t][tPozY2], t+1, 0.8);
			nrt++;
		}
	}
	printf("* Total Teritorii War: %d", nrt);
	return 1;
}



Re: Error debug - Konstantinos - 08.05.2014

The size of TeritoriuInfo array is 15 so in the loop change:
pawn Код:
if ( t >= 29 )
to:
pawn Код:
if (t == sizeof (TeritoriuInfo))