PDA

View Full Version : Error debug


[RO]Five
08/05/2014, 11:26 AM
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;
}

Konstantinos
08/05/2014, 11:33 AM
The size of TeritoriuInfo array is 15 so in the loop change:

if ( t >= 29 )

to:

if (t == sizeof (TeritoriuInfo))