23.03.2014, 01:53
Hello, I am wondering how I would go about creating an accurate iterator for vehicles, this is my current idea:
- I am trying to make one 100% alike the Iterator:Player (When the vehicle is removed with DestroyVehicle the iter is removed with Iter_Remove from the variable Vehicle, and when a vehicle is created the iter is added with Iter_Add)
My question is, will this work?
- I am trying to make one 100% alike the Iterator:Player (When the vehicle is removed with DestroyVehicle the iter is removed with Iter_Remove from the variable Vehicle, and when a vehicle is created the iter is added with Iter_Add)
My question is, will this work?
pawn Code:
new Iterator:Vehicle<MAX_VEHICLES>;
public OnVehicleSpawn(vehicleid)
{
Iter_Add(Vehicle, vehicleid);
return 1;
}
public OnVehicleDeath(vehicleid)
{
Iter_Remove(Vehicle, vehicleid);
return 1;
}
// in a function
getNumVehicles()
{
return Iter_Count(Vehicle); // will return the amount of vehicles spawned, not just the first id to be invalid.
}