Looping through vehicles with Foreach
#1

Hi guys, can someone please tell me how I can go about looping through an enum (faction vehicles) so that I can create a command to reset all unoccupied faction vehicles?

pawn Код:
enum teamCars
{
    //police
    c01,
    c02,
    c03,
    c04,
    c05,
    c06,
    c07,
    c08,
    c09,
    c010,
    c011,
    c012,
    c013,
    c014,
    c015,
    c016,
    c017,
    c018,
    c019,
    c020
}
new Cars[teamCars];
Then of course I allocate the values to my vehicles in OnGameModeInit..

Then I was creating the foreach loop like:

pawn Код:
foreach(Cars[teamCars], i)
{
//code here
}
The above clearly isn't correct.

Can someone please provide a link to a tutorial they know of that is clear and easy to understand? I have been searching but the ones out there just don't seem to help me.

Also if you're going to provide code, I would much appreciate an explanation as to what the code does and why it has to be that way round (im here to learn)... if you simply can't be arsed to do this, I will try and learn the code from reading it (i can of course).

Thank you in advance!
Reply


Messages In This Thread
Looping through vehicles with Foreach - by ross8839 - 07.06.2017, 16:01
Re: Looping through vehicles with Foreach - by Pottus - 07.06.2017, 16:07
Re: Looping through vehicles with Foreach - by ross8839 - 07.06.2017, 16:10
Re: Looping through vehicles with Foreach - by Pottus - 07.06.2017, 16:11
Re: Looping through vehicles with Foreach - by ross8839 - 07.06.2017, 16:52

Forum Jump:


Users browsing this thread: 1 Guest(s)