player.Iterator
Description
Returns a Stateless Iterator for all players on the server.
Intended for use in Generic For Loops.
See ents.Iterator for a similar function for all entities.
Internally, this function uses cached values that exist entirely within lua, as opposed to player.GetAll, which is a C++ function. Because switching from lua to C++ (and vice versa) incurs a performance cost, this function will be somewhat more efficient than player.GetAll.
Returns
2 sequental table<Player>
Table of all existing Players. This is a cached copy of player.GetAll
This table is intended to be read-only.
Modifying the return table will affect all subsequent calls to this function until the cache is refreshed, replacing all of your player.GetAll usages may come with unintended side effects because of this.
Example of bad code:
3 number
The starting index for the table of players.
This is always
This is always
0
and is returned for the benefit of Generic For Loops