Garry's Mod Wiki


function, table, any pairs( table tab )


Returns an iterator function(next) for a for loop that will return the values of the specified table in an arbitrary order.

For alphabetical key order use SortedPairs.

For alphabetical value order use SortedPairsByValue.


1 table tab
The table to iterate over.


1 function
The iterator (next).
2 table
The table being iterated over.
3 any
nil (for the constructor).


Iterates through all players on the server and prints their names.

Note: In sequential tables like player.GetAll or ents.GetAll, it's more efficient to use ipairs instead of pairs.

for k, v in pairs( player.GetAll() ) do print( v:Nick() ) end
Output: A list of players in console.

Page Links

Special Pages



Render Time: 51ms

DB GetPage 3
Generate Html 18
SaveChanges (1) 16
Render Body 0
Render Sidebar 11