#include "MyGameMode.h"
AMyGameMode::AMyGameMode()
void AMyGameMode::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
// Example code
// Convert the player's Unique Net ID (UniqueId) to a string.
FString UniqueIDString = UniqueId.ToString();
//If UniqueIDString (FUniqueNetIdRepl& UniqueId) equals "001"
if (UniqueIDString == "001")
{
//Let the player join
ErrorMessage = "";
}
else
{
// Don't let player join
ErrorMessage = "Error joining";
}
FGameModeEvents::GameModePreLoginEvent.Broadcast(this, UniqueId, ErrorMessage);
}
Replace MyprojectName with your project name, MyGameMode, with your game mode name, and AMygameModeName with your game mode name, and leave the A in front of it.
If ErrorMessage = “”; is returned as not empty, the player will not be able to join.