Download

How to get the unique Steam user id?

I’m able to see in my logs that I’m getting the Steam user id:



DevOnline: Failed to obtain steam user stats, user: 76561xxxxxxxx9271 has no stats entries


Just wondering if anyone knows how I would go about retrieving this in my code?

Have you tried OnlineSubsystemSteamworks::GetUniquePlayerId? You should be able to use the result with OnlineSubsystemSteamworks::UniqueNetIdToInt64 and OnlineSubsystemSteamworks::UniqueNetIdToPlayerName.

Thanks for the response @UnrealEverything. But how would I target a specific player if I was the server. Usually I would go through the PRI, but not sure I have the OnlineSubsystemSteamworks through the PRI (i could be wrong).

The PlayerReplicationInfo DOES have a UniqueId member variable. I am not sure it contains that specific value though. You’ll have to test that, log it directly retrieved from OnlineSubsystemSteamworks and via the PRI.
The (Pre)Login function of the gamemode has that UniqueId passed in as an argument as well and simply sets it on the PRI. Since this function is called from native code I cannot check whether this will already be the UniqueId from OnlineSubsystemSteamworks or just a “random” unique id.

If that doesn’t work you can always manually send it from client to server as well.

Could you explain why you need that info on the server?

Thanks for the response. I need it so I can re-issue a loadout to a player rejoining a server. Currently I’m using their ip, but obviously this breaks if two players from the same house are playing at the same time.

So it does not actually have to be the steam unique id. As long as it is unique per player you should be good (and is reliably reassigned to that player every time they reconnect).

I thought rejoining players are already handled somewhere? Something like their PlayerControllers are kept around even after a disconnect in case they reconnect. Not exactly sure on that, I might be mixing things with UE4 here. And I don’t know how it identifies players, as you said ip might not be enough.

I guess something like sending the unique id retrieved from onlinesubsystemsteamworks via a reliable function to the server to request their loadout being re-issued should be fine.

Yeah i’ll take a look into it. I was trying to use the UniqueId on the PRI before, but found that it was always the same per player (i think it was something something like 0x00000000 or similar).

Here is a video on how to get the Steam Player ID via blueprints if that helps.