Garry's Mod Wiki

Revision Difference

player.Iterator#560087

<function name="Iterator" parent="player" type="libraryfunc"> <description> Returns an iterator for all players on the server. This will be quite a bit faster than <page>player.GetAll</page>, especially when using the `break` keyword. </description> <added>2023.10.13</added> <realm>Shared</realm> <file line="93-L99">lua/includes/extensions/player.lua</file> <rets> <ret name="" type="function">Iterator function</ret> <ret name="" type="table">Table of all existing <page>Player</page>s.</ret> <ret name="" type="number">Will always be 0. Start index?</ret> </rets> </function> ⤶ ⤶ <example>⤶ ⤶ <example>⤶ <description>Example usage of this function.</description> <code> for i, ply in player.Iterator() do for _, ply in player.Iterator() do print( ply ) end </code> <output>Prints out all players to the console.</output> ⤶ </example></example>