foreach loop
#1

So..
If I want to loop through all my "DsVeh" can I do it with foreach instead of that other for(new blahblahblah.. ??
If yes, how? I tried with
pawn Код:
foreach(DsVeh, i)
but that obviously didn't work lol
Reply
#2

What is DsVeh, can you show where you use/apply/define it?
Reply
#3

pawn Код:
new DsVeh[sizeof(cInfo)];
and my cInfo
pawn Код:
enum CarInfo
{
    Owner[MAX_PLAYER_NAME],
    Owned,
    Color,
    Color2,
    Float: Pos_X,
    Float: Pos_Y,
    Float: Pos_Z,
    Float: Angle,
    Price
}
new cInfo[MAX_VEHICLES][CarInfo];
Reply
#4

With the "old" loop you could just do
pawn Код:
for(new i = 0; i < sizeof(DsVeh); i++)
But I'm making a roleplay gamemode from scratch so I would like everything to be the same. Not just randomly use for(new on some things and foreach on some. It looks better with only using one system and to be honest I'm kinda a freak about everything being exact..
Reply
#5

go to https://sampforum.blast.hk/showthread.php?tid=92679
and see its declaration and functions section
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)