Strange Array Index Out Of Bounds bug. - 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: Strange Array Index Out Of Bounds bug. (
/showthread.php?tid=608875)
Strange Array Index Out Of Bounds bug. -
Dokins - 06.06.2016
It only prints 131 vehicles, MAX_VEHICLES is SAMP default (1000).
pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
new rows, fields, vehicleid, x;
cache_get_data(rows, fields);
printf("Rows %d", rows); // if the rows are more than the size of the variable, reset the rows to match (to avoid run time error 4)
for(new y; y < rows; y++)
{
x = cache_get_row_int(y, vvid);
VehLModel[x] = cache_get_row_int(y, vVehModel);
VehLColour1[x] = cache_get_row_int(y, vVehColour1);
VehLColour2[x] = cache_get_row_int(y, vVehColour2);
VehLSpawnX[x] = cache_get_row_float(y, vVehSpawnX);
VehLSpawnY[x] = cache_get_row_float(y, vVehSpawnY);
VehLSpawnZ[x] = cache_get_row_float(y, vVehSpawnZ);
VehLSpawnAngle[x] = cache_get_row_float(y, vVehSpawnAngle);
VehLSiren[x] = cache_get_row_int(y, vVehSiren);
vehicleid = CreateVehicle(VehLModel[x], VehLSpawnX[x], VehLSpawnY[x],VehLSpawnZ[x], VehLSpawnAngle[x], VehLColour1[x], VehLColour2[x], -1, VehLSiren[x]);
VehicleSQLID[vehicleid] = x;//ERROR LINE ERROR LINE ERROR LINE
printf("vehicleid %d", vehicleid);
Re: Strange Array Index Out Of Bounds bug. -
Gammix - 06.06.2016
You no where check if the vehicle was actually created.
pawn Код:
if (vehicleid != INVALID_VEHICLE_ID)
VehicleSQLID[vehicleid] = x;
Re: Strange Array Index Out Of Bounds bug. -
Dokins - 06.06.2016
Could that cause issue?
Re: Strange Array Index Out Of Bounds bug. -
Gammix - 06.06.2016
Quote:
Originally Posted by Dokins
Could that cause issue?
|
Of course, the issue you are getting currently is the one.
INVALID_VEHICLE_ID is (65535) and MAX_VEHICLES is (2000), So its an index out of array's size.
Re: Strange Array Index Out Of Bounds bug. -
Dokins - 06.06.2016
YOU ARE A HERO.
Re: Strange Array Index Out Of Bounds bug. -
Sew_Sumi - 06.06.2016
SAMPs default is 2000.
GetVehiclePoolSize() is a good thing to look at.