how to use foreach
#1

I understand that it is to optimize the server and avoid the use of for but I do not understand its operation try to read this but I still do not understand.
https://sampforum.blast.hk/showthread.php?tid=588526
please explain how it is used.
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)