Ali Şahan Yalçın
DocsStep 3: Find and join

Tutorial: a working multiplayer menu

Step 3: Find and join

List the sessions that exist and join the one the player picked.

Hosting is half of it. Now the other side: finding a session and getting into it.

Store the results

Searching gives you an array of results. A dropdown holds only text, so you need to keep the real results somewhere in order to look up what the player picked.

  1. In the Variables panel, click + to add a variable.
  2. Name it FoundSessions.
  3. Set its type to Steam Session Search Result.
  4. Click the icon beside the type and change it from a single value to an Array.

Compile.

Wire the Find button

Add an On Clicked event for Button_Find, the same way you did for Host.

From its execution pin, add Find Sessions and leave Max Results at its default.

From the node's On Success pin:

  1. Add Set Found Sessions, connecting the node's Sessions output into it. The results are now saved.
  2. Drag in Combo_Sessions and add Clear Options, so a second search does not stack on top of the first.
  3. Add a For Each Loop and connect the Sessions array to its Array pin.

Inside the loop body:

  1. Drag off Array Element and add Break Steam Session Search Result.
  2. Add an Append node and build a readable line from Session Name, a space, Current Players, a slash, and Max Players.
  3. Drag in Combo_Sessions again, add Add Option, and feed the appended text into it.
INFO: Append is needed because Add Option takes one string. Use a Format Text node instead if you prefer named slots to a chain of Append pins.

Wire the Join button

Add an On Clicked event for Button_Join.

The dropdown knows which row is selected, and row order matches array order, so the index is the link between the two.

  1. Drag in Combo_Sessions and add Get Selected Index.
  2. Drag in FoundSessions and add Get (a copy), feeding the selected index into its index pin.
  3. Drag off that and add Break Steam Session Search Result.
  4. From the button's execution pin, add Join Session.
  5. Connect the Lobby field from the break node into Join Session's Session pin.

Leave Password empty. Leave Travel ticked this time. That covers both cases: if the host has already started, joining takes you straight into the match, and if they have not, this client follows them automatically the moment they do. Untick it only if you want to handle the travel yourself.

WARNING: A combo box has nothing selected until the player picks a row, and Get Selected Index returns -1 then. Clicking Join before choosing reads past the end of the array and hands Join Session an empty lobby, which fails with a message that makes no sense. Either pick a row before clicking, or branch on the index being 0 or more first.

Report the outcome

Join Session reports a Diagnosis on both output pins rather than a bare true or false. Use it.

  1. From On Failure, drag off Diagnosis and add Break Steam Join Diagnosis.
  2. Feed its Player Message field into Set Text on Text_Status.

That field is already written for a player to read: wrong password, session full, different version, and so on. There is nothing for you to translate.

From On Success, set the status to Joined.

Compile and save.

What you can check alone

Press Play, click Host, then click Find. Your own session should appear in the dropdown.

That proves hosting and searching work. It does not prove joining works, because you cannot join yourself. For that you need two players, which is the next page.

WARNING: Against real Steam, two Play In Editor windows share one Steam account and therefore one identity, so the second player joining is really the host joining their own lobby. Nothing in a plugin can change that, because the account belongs to the machine. The next page has the way around it.

Where to go next

Testing with two players.