Ali Şahan Yalçın
DocsLobby players and the host

Lobbies

Lobby players and the host

List who is in a lobby, find the host, and react when people come and go.

Listing everyone

Call Get Lobby Members with a lobby ID. You get an array of Steam Lobby Member:

FieldMeaning
PlayerTheir Steam ID
Persona NameTheir Steam display name, ready to show
Is Local PlayerTrue for the player holding this copy of the game
Is OwnerTrue for the host

That is everything a player list widget needs, with no follow up calls.

For just a count, use Get Lobby Member Count.

Finding the host

Two ways, depending on what you need:

  • Get Lobby Owner returns the host's Steam ID.
  • Is Lobby Owner returns whether the local player is the host, which is what you usually want for showing or hiding host only buttons.
  • The host is whoever created the lobby. If they leave, Steam picks a new one automatically.

    INFO: Only the host can change lobby data and lobby settings. Calls like Set Lobby Data and Set Lobby Joinable fail for everyone else, which is correct behaviour rather than a bug.

    Reacting to people joining and leaving

    Bind On Lobby Member Changed on the SteamForge Lobbies subsystem:

    OutputMeaning
    LobbyWhich lobby
    MemberWho changed
    ChangeEntered, Left, Disconnected, Kicked or Banned

    The usual handler simply calls Get Lobby Members again and rebuilds the list.

    Disconnected is worth treating differently from Left. Left means they chose to go. Disconnected means they crashed or lost connection, which is the case host migration exists for.

    Per player data

    Each member can publish their own key and value pairs, which is how you carry a chosen team, character or ready state.

  • Set Lobby Member Data sets one of your own values. You can only ever set your own.
  • Get Lobby Member Data reads anyone's.
  • A ready check is the classic use:

  • When the player presses Ready, call Set Lobby Member Data with key ready and value 1.
  • Everyone receives On Lobby Data Changed.
  • In the handler, loop the members, read each one's ready value, and update your UI.
  • On Lobby Data Changed

    This fires for both kinds of change. The Member output tells you which:

  • A valid Member means that player's own data changed.
  • An invalid Member means the lobby's shared data changed.
  • Check with Is Valid (Steam ID) before assuming.

    Where to go next

    Lobby data, for the shared settings everyone reads.