Num Players in Session isn't refreshed?

I have 2 players waiting in a Steam lobby. When a 3rd player does a FindSession, it always returns 1/4 people in that game using the SessionResults GetCurrentPlayers (or NumPublicConnections - NumOpenPublicConnections).

I thought the player count would be updated for me automatically. What’s the appropriate response here? To call UpdateSession on the GameMode PostLogin after a player connects?

ping…

I managed to get it working by updating the session joinability in the post login of my game mode:

Super::PostLogin(NewPlayer);

UWorld* const World = GetWorld();
if (World)
{
	AGameModeBase* const Game = World->GetAuthGameMode();
	if (Game)
	{
		if (Game->GameSession)
		{
			FJoinabilitySettings OutSettings;
			Game->GameSession->GetSessionJoinability(GameSessionName, OutSettings);

			Game->GameSession->UpdateSessionJoinability(GameSessionName,
				OutSettings.bPublicSearchable, OutSettings.bAllowInvites, 
				OutSettings.bJoinViaPresence, OutSettings.bJoinViaPresenceFriendsOnly);
		}
	}
}
1 Like

This worked for me, thanks! But you’re already doing this inside your game mode so it’s not necessary to get the World and then get the GameMode from it, you’re just cycling back to where you started.

This doesn’t work for me, as I get negative player count numbers (such as -17). The code I used is the same, except that being already in GameMode I do not go through world:

void AMST_GameMode::PostLogin(APlayerController* NewPlayer)
{
	Super::PostLogin(NewPlayer);

	if (GameSession)
	{
		FJoinabilitySettings OutSettings;
		GameSession->GetSessionJoinability(GameSessionName, OutSettings);

		GameSession->UpdateSessionJoinability(GameSessionName,
			OutSettings.bPublicSearchable, OutSettings.bAllowInvites,
			OutSettings.bJoinViaPresence, OutSettings.bJoinViaPresenceFriendsOnly);
	}
}

Any ideas?