SA-MP Forums Archive
Question about foreach loop - 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: Question about foreach loop (/showthread.php?tid=263655)



Question about foreach loop - OUL - 22.06.2011

pawn Код:
#define ClearChat(%1,%2) for(new c; c < %2; c++) SendClientMessage(%1,0xFFFFFFAA,"   ")
Is it posible to make that loop with foreach?

Example of normal loop:

pawn Код:
for(new c; c < 15; c++)
How i can make that in foreach ( if i can )


Re: Question about foreach loop - =WoR=Varth - 22.06.2011

pawn Код:
foreach(ClearChat,c)
Never test that.


Re: Question about foreach loop - OUL - 22.06.2011

I don't understand your code :S


Re: Question about foreach loop - =WoR=Varth - 23.06.2011

Me neither. I just use foreach for loop through player because AFAIK
pawn Код:
for (new i = 0; i != MAX_PLAYERS; ++i)
{
    if (IsPlayerConnected(i))
    {
        printf("Player %d is connected", i);
    }
}
pawn Код:
foreach (Player, i)
{
    printf("Player %d is connected", i);
}



Re: Question about foreach loop - XFlawless - 23.06.2011

Use Iterator.


Re: Question about foreach loop - Donya - 23.06.2011

pawn Код:
new Iterator:MyIter<15>;
for(new i = 0; i != 15; i++) Iter_Add(MyIter, i);
foreach(MyIter, i)
{
//hello
}