foreach
#1

Hello. I want to be sure.

I just change all my normal loops like this

pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
to this?

pawn Код:
foreach (Player, i)
{
    // code
}
Also how can I convert these loops

pawn Код:
for (pID=0; pID<=MAX_PLAYERS; pID++)
and this

pawn Код:
for(new i; i < sizeof(Seats); i++)
Thanks
Reply
#2

hm its beause in the pID loop , is getting a players name like /getid <name>

ok and can you show me how to make that seat iterator?

EDIT:

pawn Код:
stock SendClientMessageToTeam(team, color, text[]) //By Alex "******" Cole
{
    foreach (Player, i)
    {
        if (gTeam[i] == team) SendClientMessage(i, color, text);
    }
}
will this work aswell?

EDIT: some loops doesnt work with foreach, ill leave foreach for now.. thanks anyways
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)