#include "OnlineSamplePlayerController.h" #include "OnlineSample/GameInstance/OnlineSampleGameInstance.h" #include "OnlineSample/GameInstance/OnlineSampleOnlineSubsystem.h" AOnlineSamplePlayerController::AOnlineSamplePlayerController() { } void AOnlineSamplePlayerController::BeginPlay() { Super::BeginPlay(); //////////////////////////////////////////////// /// ONLINE SERVICES // Register this player with the Online Services UOnlineSampleGameInstance* GameInstance = Cast<UOnlineSampleGameInstance>(GetWorld()->GetGameInstance()); UOnlineSampleOnlineSubsystem* OnlineSubsystem = GameInstance->GetSubsystem<UOnlineSampleOnlineSubsystem>(); ULocalPlayer* LocalPlayer = Super::GetLocalPlayer(); if (LocalPlayer) { FPlatformUserId LocalPlayerPlatformUserId = LocalPlayer->GetPlatformUserId(); if (OnlineSubsystem) // null-check subsystem before access { UE_LOG(LogOnlineSampleOnlineSubsystem, Log, TEXT("Registering PlatformUserId: %d"), LocalPlayerPlatformUserId.GetInternalId()); OnlineSubsystem->RegisterLocalOnlineUser(LocalPlayerPlatformUserId); // Read the Title File and display contents on-screen FString TitleFileContent = OnlineSubsystem->ReadTitleFile(FString("StatusFile"), LocalPlayerPlatformUserId); if (GEngine) { GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Black, TitleFileContent); } } } /////////////////////////////////////////////// /// NEXT SECTION... } void AOnlineSamplePlayerController::EndPlay(EEndPlayReason::Type EndReason) { Super::EndPlay(EndReason); }