foreach Vehicle iterator
#1

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?

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.
}
Reply


Messages In This Thread
foreach Vehicle iterator - by Dubya - 23.03.2014, 01:53
Re: foreach Vehicle iterator - by MP2 - 23.03.2014, 02:03
Re: foreach Vehicle iterator - by Dubya - 23.03.2014, 02:07
Re: foreach Vehicle iterator - by MP2 - 23.03.2014, 02:20
Re: foreach Vehicle iterator - by Dubya - 23.03.2014, 02:23
Re: foreach Vehicle iterator - by MP2 - 23.03.2014, 02:25

Forum Jump:


Users browsing this thread: 1 Guest(s)