Steam Multiplayer with more than two players

Hello,

If I run the game using -nosteam on a LAN I can get three computers to join fine. But if I run the game with 3 steam accounts on three computers over the internet, once one player joins, the other player can no longer find the game.

Any ideas why?

Thanks!

Okay so I haven’t tried it yet but the answer might be this :

In the CreateSession() method over in the GameInstance, I suppose you should have sth like :

SessionSettings.NumPublicConnections = 2;

which only allows you to join in 2 people on the same server, or lobby I should say in this case.

The reason why you’re able to join 3 people in LAN mode is because of the bug mentioned in Section 62 where NumOpenPublicConnections doesn’t count in the Host player for some reason…

Again, I’m not sure of this fix and I haven’t reached the end of the section yet either :blush:

PS : Please let me know if this fixes your issue.
PS2 : Sorry if there are English mistakes

1 Like

Thanks for the reply!
Unfortunately, this isn’t the problem. I tried using SessionSettings.NumPublicConnections = 3 or 4 or 8 etc.

Seems strange. What other settings have you tried changing?

Update on this issue. I can successfully have more than 2 players if we coordinate and click join at the same time. But if one player waits to join, then they can’t join anymore.

edit:
The host and first player can always join the game. But any players after that cannot join unless we coordinate and click join at the same time, then all players can join fine.
When I refresh my server list after a first player joins, the server is no longer found, even though my SessionSettings.NumPublicConnections is always > 2.
When 2 or more joining players can see the game on the server list and the first one joins, then (without refreshing) the 2nd player tries to join shortly afterwards, the Address returned by SessionInterface->GetResolvedConnectString(SessionName, Address) returns an empty string, which results in a failed attempt to join a game. When I use the Null Online Subsystem over LAN, things are working as expected. Does anyone have any ideas what I could be doing wrong?

edit 2:

void UBoiGameInstance::Host(FGameSettings Settings)
{
	GameSettings = Settings;
	GameSettings.bInitialized = true;

	if (GameSettings.MaxPlayerCount < 1)
	{
		UE_LOG(LogTemp, Warning, TEXT("Invalid Player Count"));
		return;
	}

	if (!SessionInterface.IsValid()) 
	{
		UE_LOG(LogTemp, Warning, TEXT("Invalid Session Interface"));
		return;
	}

	FNamedOnlineSession* ExistingSession = SessionInterface->GetNamedSession(NAME_GameSession);
	if (ExistingSession)
	{
		SessionInterface->DestroySession(NAME_GameSession);
	}
	else
	{
		CreateSession();
	}
}

void UBoiGameInstance::CreateSession()
{
	if (!SessionInterface.IsValid()) { return; }

	FOnlineSessionSettings SessionSettings;
	SessionSettings.NumPublicConnections = GameSettings.MaxPlayerCount;
	SessionSettings.bShouldAdvertise = true;
	SessionSettings.bAllowJoinInProgress = true;
	SessionSettings.bIsDedicated = false;
	SessionSettings.bIsLANMatch = (IOnlineSubsystem::Get()->GetSubsystemName() == "NULL");
	SessionSettings.bUsesPresence = true;
	SessionSettings.bAllowJoinViaPresence = true;
	SessionSettings.Set(SERVER_NAME_SETTINGS_KEY, GameSettings.ServerName, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);

	SessionInterface->CreateSession(0, NAME_GameSession, SessionSettings);
}

void UBoiGameInstance::OnCreateSessionComplete(FName SessionName, bool Success)
{
	if (!Success)
	{
		UE_LOG(LogTemp, Warning, TEXT("Could not create session"));
		return;
	}

	if (GEngine) { GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, TEXT("Hosting")); }
	
	GetWorld()->ServerTravel("/Game/FPSBois/Maps/Lobby?listen");
}

Has anybody tried this using the non debug steam setup? Might it be a restriction on that?

1 Like

Looks like you’re right! We built the project to an executable and ran it standalone and are able to join with multiple players fine.

Thanks Sam!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms