Hi all,
I’m currently using Aws’s FlexMatch to matchmake players to servers but need to pass a playerid from my game client into my gamemode’s PreLogin function on the server. There does not seem to be a straightforward way to do that?
The client is connecting to the server by calling ClientTravel and I have tried passing the playerid as a key-value pair appended to the url (e.g. “52.xx.xxx.xxx:7777?user-id=123456” ).The UniqueId parameter always seems to default to the name of the connecting client + a random hash however.
Any ideas?
I know this is a very late response, but what you can do is instead of passing the unique id through ClientTravel
, which I don’t think you can do as far as I know, you can override the game mode class’ PreLogin
function and pass whatever value for the UniqueId
parameter of the parent class’ PreLogin
function. Here’s an example of the implementation of the function override in c++,
void AYourGameMode::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
const FString& RandomValue = UGameplayStatics::ParseOption(Options, "RandomValue");
Super::PreLogin(Options, Address, FUniqueNetIdString(RandomValue), ErrorMessage);
}
In this case, the client passes an option named “RandomValue” when connecting to the server, and the value for that option is passed to a call to Super::PreLogin
.
This suggestion doesn’t work because FString& cannot be converted to UniqueNetIdRepl&.
You’d need to use this type to create from a string:
Thanks, I edited my answer to reflect your comment’s feedback.
I had to do -
const FString& RandomValue =
UGameplayStatics::ParseOption(Options,
“RandomValue”);
Super::PreLogin(Options, Address, FUniqueNetIdRepl(FUniqueNetIdString(RandomValue)),
ErrorMessage);
Also don’t forget to include the header - include “OnlineSubsystemTypes.h”