SA-MP Forums Archive
Help with foreach - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with foreach (/showthread.php?tid=224686)



Help with foreach - ajwar - 12.02.2011

Hi, having problems with converting this:

pawn Код:
for(new i = 1; i < MAX_BUYABLE_VEH; i++)
to foreach. Anyone who can show it?


Re: Help with foreach - xxmitsu - 12.02.2011

Код:
new Iterator:BVeh<MAX_BUYABLE_VEH>;

Itter_Add(BVeh, vehicleid1);
Itter_Add(BVeh, vehicleid2);
Itter_Add(BVeh, vehicleid3);
Itter_Add(BVeh, vehicleid4);

foreach(BVeh, i) printf("vehicle: %d",i); // this is : for(new i = 1; i < MAX_BUYABLE_VEH; i++)

Itter_Remove(BVeh, vehicleid3);



Re: Help with foreach - ajwar - 12.02.2011

pawn Код:
stock GetNewVehID()
{

    for(new i = 1; i < MAX_BUYABLE_VEH; i++)
    {
        if(!vInfo[ivCreated[i]][vPrice]) return i;
    }
    return 255;

}
I want to use foreach in this function, but when i use your's example i get errors.