foreach(Player,i or for(new loop
#1

What should i use for this? that with foreach or with a loop?

Код:
foreach(Player,i)
	{
    Delete3DTextLabel(spawnprotection[i]);
    }
    for(new i=0;i<MAX_PLAYERS;i++)
    {
       Delete3DTextLabel(spawnprotection[i]);
	}
Reply
#2

They are both the same, but I think foreach is more faster.
Reply
#3

Always use foreach
Reply
#4

foreach was created for a reason, one of the reasons if because it was better and more efficient than using for( loops. So yes, in this instance, you should be using foreach.
Reply
#5

foreach is faster as it loops through the online player count only.

The default loop will loop through MAX_PLAYERS, regardless of how many players are online, meaning excess looping.

So, due to this fact may I suggest you use foreach.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)