Question about foreach loop
#1

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 )
Reply
#2

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

I don't understand your code :S
Reply
#4

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);
}
Reply
#5

Use Iterator.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)