22.07.2017, 13:56
So, I have an iterator to hold the server vehicles;
This works, however, when I call the function to destroy the vehicle inside a loop like;
It's crashing the server. When I use DestroyVehicle for a specific vehicle id, it works fine tho. The printf inside the DestroyVehicle function does not print out anything when it crashes the server nor there are any crash log, server just freezes at it is.
Can anyone help me point out the issue? I am using the standalone version of foraech.
PHP код:
new Iterator:Vehicles<MAX_VEHICLES>;
vehicle_Create(model, Float:x, Float:y, Float:z, Float:a, c1, c2, delay)
{
new vehicleid = CreateVehicle(model, x, y, z, a, c1, c2, delay);
Iter_Add(Vehicles, vehicleid);
printf("Added vehicleid %i to the iterator.", vehicleid);
Vehicle(vehicleid, Model) = model;
Vehicle(vehicleid, Fuel) = vehicle_ReturnFuelTank(vehicleid);
Vehicle(vehicleid, Color1) = c1;
Vehicle(vehicleid, Color2) = c2;
return vehicleid;
}
vehicle_Destroy(vehicleid)
{
Iter_Remove(Vehicles, vehicleid);
DestroyVehicle(vehicleid);
printf("Removed vehicleid %i from the iterator.", vehicleid);
}
#if defined _ALS_DestroyVehicle
#undef DestroyVehicle
#else
#define _ALS_DestroyVehicle
#endif
#define DestroyVehicle vehicle_Destroy
PHP код:
foreach(new i : Vehicles)
{
// Few if statements on this line to check for specific vehicles to delete.
{
DestroyVehicle(i);
}
}
Can anyone help me point out the issue? I am using the standalone version of foraech.