Garry's Mod Wiki

player.GetAll

player.GetAll

  table player.GetAll()

Description

Gets all the current players in the server (not including connecting clients).

This function returns bots as well as human players. See player.GetBots and player.GetHumans.
This function returns a sequential table, meaning it should be looped with ipairs instead of pairs for efficiency reasons.

Returns

1 table
All Players currently in the server.

Example

Prints all the players currently in the server.

Output:
1 = [Player][1][Player1] 2 = [Player][2][Bot01] 3 = [Player][3][Bot02]

Example

Prints the number of players in the server. The same output can be achieved more efficiently with player.GetCount.

print(#player.GetAll())
Output:
3

Example

The output of the players name in the console.

for i, v in ipairs( player.GetAll() ) do print( v:Nick() ) end
Output:
Player1 Player2 Player3

Special Pages


Wikis

?

Render Time: 26ms

DB GetPage 2
Generate Html 5
SaveChanges (1) 6
Render Body 0
Render Sidebar 10