Garry's Mod Wiki

pairs

  function, table, any pairs( table tab )

Description

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

Arguments

1 table tab
The table to iterate over.

Returns

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

Example

Iterates through all PlayerInitialSpawn hooks on the server and prints their unique identifiers and called function.

for k, v in pairs( hook.GetTable().PlayerInitialSpawn ) do -- The custom name given in the second argument of the hook.Add function. -- Example : "myCustomSpawnFunc". print( "Unique identifier:", k ) -- The hook function. -- Example : "function: 0x3a3f2c80". print( "Called function:", v ) end
Output: A list of all hooks.