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: foreach (
/showthread.php?tid=252012)
foreach -
fissekarl - 29.04.2011
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
Re: foreach -
fissekarl - 29.04.2011
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