Strange Array Index Out Of Bounds bug.
#1

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);
Reply
#2

You no where check if the vehicle was actually created.

pawn Код:
if (vehicleid != INVALID_VEHICLE_ID)
    VehicleSQLID[vehicleid] = x;
Reply
#3

Could that cause issue?
Reply
#4

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.
Reply
#5

YOU ARE A HERO.
Reply
#6

SAMPs default is 2000.

GetVehiclePoolSize() is a good thing to look at.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)