How to Know if am i listen server before PlayerController exists?

I want to show a Loading Screen in all cases except to a dedicated server.

I was using this, but it return true if i’m a dedicated or listen server

GameInstance->IsDedicatedServerInstance();

Then i tried using this:


const APlayerController* PC = GameInstance-> GetFirstLocalPlayerController(GetWorld());
	if(IsValid(PC))
	{
		const ENetMode NetMode = PC->GetNetMode();	
		if( NetMode == ENetMode::NM_ListenServer) return true;
		if( NetMode == ENetMode::NM_DedicatedServer) return false;
	}
	return true;

But it does not works because the PlayerController has not been created yet… so it is null.

Is there any other way to know if am i a listen server?
Thank you so much!!


Your only option before the PlayerController is created could be to use the Engine TravelUrl and test it if it has the option “listen”.

1 Like

Hi, thanks for your reply!!

Do you know how to get the right URL?
I tried these things but none of them is the right URL (they have not options, it is the map path only)

FURL URL = (GEngine && GetWorld()) ?  GEngine->LastURLFromWorld(GetWorld()) : FURL();
FURL URL = GetWorld() ?  GetWorld()->URL : FURL();
FURL URL = GetWorld() ?  GetWorld()->NextURL : FURL();
FURL URL = GetWorld() ?  GetWorld()->GetLocalURL() : FURL();

Thank you so much!!

It probably won’t work with this method while using Play In Editor mode unless if you start as Standalone and then create the Listen Server.

1 Like

Thank you so much for your help!! :heart:

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