Garry's Mod Wiki

Revision Difference

player.GetAll#512617

<function name="GetAll" parent="player" type="libraryfunc">⤶ <description>⤶ Gets all the current players in the server (not including connecting clients).⤶ ⤶ <note>This function returns bots as well as human players. See <page>player.GetBots</page> and <page>player.GetHumans</page>.</note>⤶ </description>⤶ <realm>Shared</realm>⤶ <rets>⤶ <ret name="" type="table">All <page>Player</page>s currently in the server.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Prints all the players currently in the server.</description>⤶ <code>PrintTable( player.GetAll() )</code>⤶ <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output>⤶ 1 = [Player][1][Player1]⤶ 2 = [Player][2][Bot01]⤶ 3 = [Player][3][Bot02]⤶ </output>⤶ ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>Prints the number of players in the server. The same output can be achieved more efficiently with <page>player.GetCount</page>.</description>⤶ <code>print(#player.GetAll())</code>⤶ <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output>3</output>⤶ ⤶ </example>