21.08.2010, 00:04
Foreach is faster. All of you guys are WRONG. Foreach doesn't loop through all players and check if they are online.
When a player connects it adds their id into an Iteration. Foreach loops through the iteration of connected id's.
Example:
It wont loop through all 100 players checking if 0,5,99 are connected. Since it is in the interation, it will only pass through the id's: 0, 5, and 99. Nothing else.
If you have two players in the server with id 40 and 60, it wont loop through numbers 1-60, it will only output id 40, and 60.
When a player connects it adds their id into an Iteration. Foreach loops through the iteration of connected id's.
Example:
Code:
id 0 connected id 5 connected id 99 connected
If you have two players in the server with id 40 and 60, it wont loop through numbers 1-60, it will only output id 40, and 60.