Open-GTO / foreach

foreach standalone include (non y_iterate version)
Other
22 stars 8 forks source link

Destroying a vehicle in a foreach causes out of bounds error #3

Closed TommyB123 closed 7 years ago

TommyB123 commented 7 years ago

Example:

foreach(new v: Vehicle)
{
    if(aspawned{v})
    {
        if(!IsVehicleOccupied(v))
        {
            CarColor[v][0] = 1;
            CarColor[v][1] = 1;
            AdminLocked{v} = false;
            VehicleSpawnedBy[v][0] = 0;
            DestroyVehicle(v);
            ClearVehicleData(v);
        }
    }
}
ziggi commented 7 years ago

Thanks, I forgot to add DestroyVehicleSafe and DestroyActorSafe functions for this, example of usage here.