how to use 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)
+--- Thread: how to use foreach (
/showthread.php?tid=660720)
how to use foreach -
ChrisPa - 11.11.2018
Re: how to use foreach -
lollypap54 - 11.11.2018
You write:
Код:
foreach(new i : Player)
{
//Code
}
Instead of:
Код:
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
//Code
}
}
Also if you want to loop all existing vehicles you use Vehicle instead of Player.
That's all you need to know.