Quick question about foreach
#1

Here you go:

Код:
foreach(new i : Player)
{
        if(IsPlayerConnected(i)) // Is this necessary?
        { 
                // Do stuff.
        }
}
Thank you.
Reply
#2

No. It handles that internally.
Read this if you're interested in reading a discussion about for vs foreach: https://sampforum.blast.hk/showthread.php?tid=169782
Reply
#3

also you dont even need to use that new i : Player,


just use foreach(Player,i)
Reply
#4

Quote:
Originally Posted by ikey07
Посмотреть сообщение
just use foreach(Player,i)
That syntax is deprecated.
Reply
#5

PHP код:
foreach(new Player)
{
    
// Do stuff.

foreach already checks if is online, because he only will be on "iter" if is online.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)