Unique ID for player that's persistent between level?

Hi!

I want a unique ID for each player so that I can associate some data with a player, even if they reconnect. I see APlayerState has two members, int32 PlayerId and FUniqueNetIdRepl UniqueId. The comments says that PlayerId’s value will depend on the subsystem used. I can’t see that would be the case though since its assigned by GetNextPlayerID() which just increments an integer when registering a player, leading to a new ID every time a player is registered. The inactive player arrays doesn’t seem to hold player states from previous level or more than a fixed number.

FUniqueNetIdRepl UniqueId doesn’t sound very reliable either since it e.g. can depend on date and time according to the comments.

I see you can save a client’s network address but that doesn’t seems very reliable either since what if many players are behind a router with NAT? That would result in the same address meaning they can actually get some other player’s player state when connecting. EDIT: I see that inactive player states are found by comparing the network address and the player name. This is not good enough for me. Players with the same IP could then just change names and reconnect, allowing e.g. a high ranked player joining a low stats game.

Is there a safe, persistent between levels way to see if a player has been on the server before, provided that I would save this ID when needed? How can I achieve this?

You will definetely need some sort of external database to hold such information. RESTful architecture is pretty good choice for it.

OnlineSubsystem player name/id?

So basically UniqueId then. The comment was very confusing but after reading some code, I found out that this is basically the OnlineSubsystem userID returned. This can still be null but that’s another problem.

I will try using the OnlineSubsystem.