S&box Wiki

Revision Difference

LobbySystem#561886

<cat>Code.Network</cat>⤶ <title>Lobby System</title>⤶ ⤶ # Lobby System⤶ ⤶ The Lobby System exists so you can create, join, and query lobbies in a way that suits your games.⤶ ⤶ ### Create a Lobby⤶ ⤶ By default, adding a Network Helper to your scene will create a lobby when the scene is loaded. However, if you want more control, you can do this yourself.⤶ ⤶ ```cs⤶ if ( !GameNetworkSystem.IsActive )⤶ {⤶ GameNetworkSystem.CreateLobby();⤶ }⤶ ```⤶ ⤶ ### Join a Lobby⤶ ⤶ You can easily join an existing lobby, too.⤶ ⤶ ```cs⤶ GameNetworkSystem.Connect( lobby.LobbyId );⤶ ```⤶ ⤶ ### Querying for Lobbies⤶ ⤶ To get a list of all lobbies, use the `Network` global manager.⤶ ⤶ ```cs⤶ List<LobbyInformation> lobbies;⤶ lobbies = await Networking.QueryLobbies( "myorg.ident" );⤶ ```⤶ ⤶ ### Setting the default Launch Mode⤶ ⤶ The default launch mode determines the lobby behaviour when your game is run. You can find the options in the editor by clicking Project > Settings, and then clicking Game Setup.⤶ ⤶ - *Normal*: Creates a new game, without any considerations for lobbies.⤶ - *Launcher*: Like normal, but allows a user to select their map before launching.⤶ - *Quick Play*: Immediately attempts to place a player in an existing lobby. If none is available, creates a new game.⤶ ⤶ None of these options will automatically create lobbies for you. It is up to your game (typically the Net Helper component) to create a lobby when the game is started.⤶ ⤶ <upload src="ae247/8dc792dfa010125.png" size="20075" name="image.png" />