How to access map travel arguments from dedicated server in blueprints?

Hello,

I have a multiplayer game which hosts games as a dedicated server.

When I connect to the game through my game client, I have it run a console command “open 127.0.0.1:7777?token=xyzxyz” where 127.0.0.1 is the server IP address and xyzxyz is a unique session token generated elsewhere that needs to be sent from the client to the server.

My question is “How can I retrieve the token value on the server from a blueprint? Preferably from my custom GameMode blueprint?”

Looking into this, I found: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums

Leading me to: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AGameMode/InitNewPlayer/index.html

Unfortunately, InitNewPlayer does not seem to be overridable in a GameMode blueprint. So far, I’ve avoided using C++ for this project (although it is setup as a C++ project and I kind of sort of know C++). So if C++ is the only way, so be it. But really, is there no other way? I simply cannot access those parameters from blueprints?

If that’s the case, can anyone provide any additional pointers? I still have a game mode in a blueprint with lots of logic I don’t want to rewrite in c++; if i’m switching to c++, doesn’t that mean I’m subclassing game mode again and adding in this custom logic? Is there any way for me to expose just this method to my blueprint somehow?

Any guidance is greatly appreciated!

I believe you will need C++ for this. But you only have to write one object. You can keep all the rest of your stuff in blueprints. Here the C++ I use to do what you want:

This line goes in your MyGameMode.h file:

FString InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, const FString& Options, const FString& Portal);

This function goes in your MyGameMode.cpp file:

FString AMyGameMode::InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, const FString& Options, const FString& Portal)
{
	FString retString = Super::InitNewPlayer(NewPlayerController, UniqueId, Options, Portal);

	//Read your token
	FString MyTokenString = UGameplayStatics::ParseOption(Options, TEXT("token"));

	//Assign MyTokenString to some blueprint readable value so you can access it in your BP's	

	return retString;
}

Thanks man, looks pretty straightforward, I will give this a try!