So I am currently making a crude login system for my game. If anyone knows of an easier or better way let me know. Here’s my current system, my PlayerController contains a UStruct called FLoginSystem that i’m using to handle my login variables. In my GameMode, i have a timer that checks though the list of PlayerControllers and see if the UStruct variable TryLogin is true and if so check a userlist file to authenticate the username and password. Then if the username and password is valid or not, set the UStruct variables LoginFailed and LoggedIn.
My Problem:
Either I am doing this completely wrong or I am missing a step, but I keep getting the annoying vs syntax error for the DOREPLIFETIME in AMyPlayerController::GetLifetimeReplicatedProps. Am I missing a header? or am I missing a simple step. I have looked at Rama’s UStruct tutorial, but still can’t seem to get it right.
My Code:
AMyPlayerController.h
#pragma once
#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FLoginSystem
{
GENERATED_USTRUCT_BODY()
// Player Login Info
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LoginInfo")
FString Username;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LoginInfo")
FString Password;
// Player States
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PlayerStates")
bool TryLogin;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PlayerStates")
bool LoginFailed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PlayerStates")
bool LoggedIn;
};
UCLASS()
class TARRAGON_API AMyPlayerController : public APlayerController
{
GENERATED_UCLASS_BODY()
UPROPERTY(Replicated, RepRetry)
class FLoginSystem PlayerLoginSystem;
};
AMyPlayerController.cpp
#include "Tarragon.h"
#include "MyPlayerController.h"
AMyPlayerController::AMyPlayerController(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
PlayerLoginSystem.TryLogin = false;
PlayerLoginSystem.LoginFailed = false;
PlayerLoginSystem.LoggedIn = false;
}
void AMyPlayerController::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DORREPLIFETIME(AMyPlayerController, PlayerLoginSystem);
}