Garry's Mod Wiki

Garry's Mod Wiki

  number player.GetCountConnecting()

Description

Returns the amount of players connecting to the server, but not yet spawned in.

player.GetCountConnecting() + player.GetCount() would result in the total player count on this server.

Returns

1 number
Number of players still connecting.

Example

Track how many players are connecting on the client.

local PlayerCountConnecting = 0 hook.Add("PlayerConnect", "PlayerGetCountConnecting", function() PlayerCountConnecting = PlayerCountConnecting + 1 end) gameevent.Listen("player_disconnect") hook.Add("player_disconnect", "PlayerGetCountConnecting", function() PlayerCountConnecting = math.max(0, PlayerCountConnecting - 1) end) gameevent.Listen("player_activate") hook.Add("player_activate", "PlayerGetCountConnecting", function() PlayerCountConnecting = math.max(0, PlayerCountConnecting - 1) end) concommand.Add("player_count_connecting", function(ply) print("Players currently connecting: " .. PlayerCountConnecting) end)

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...