That’s the problem. SteamID is a unique ID across every game that you play but PlayerID not.
PlayerID = 256
SteamID = STEAM_X:X:XXXXXX
In a world with persistence data a SteamID will be very useful to store data in database.
That’s the problem. SteamID is a unique ID across every game that you play but PlayerID not.
PlayerID = 256
SteamID = STEAM_X:X:XXXXXX
In a world with persistence data a SteamID will be very useful to store data in database.
As i already explained. That is not the SteamID. The UniqueID is platform dependent, the PlayerID is only valid while the client connected to the server (Session ID?).
If you want to store information about your users, you need the steam id. (Credits / User Points / Stats / Ranking and so on…)
Kheka i would make a new UCLASS with static methods exposed to the blueprint api that returns the SteamID as an FString.
That would be great if you have some time for us. You will be in my “people to love list”
My bad, haven’t read the whole thread again. Though i remember Epic saying that it centainly does contain the SteamID.
If not than it is bad, because i’m saying this all the time xD
I looked up the source so i know
There should be a function returning the steamid in blueprints, but there isn’t (Feature request maybe?)
@Azarus how can you access FUniqueNetIdRepl / FUniqueNetIdSteam for each player exactly? some sample code would be nice.
The only way I have found to get the steamId so far is:
PlayerController->PlayerState->GetNetDriver()->LowLevelGetNetworkNumber();
But It’s probably not the best method.
As i remember it should return the 64bit steamid as an FString if the platform is Steam.
FString SteamID = GetWorld()->GetFirstPlayerController()->PlayerState->UniqueId->ToString();
/** The id used by the network to uniquely identify a player.
* NOTE: the internals of this property should *never* be exposed to the player as it's transient
* and opaque in meaning (ie it might mean date/time followed by something else).
* It is OK to use and pass around this property, though. */
UPROPERTY(replicatedUsing=OnRep_UniqueId)
FUniqueNetIdRepl UniqueId;
Yup, that also worked thanks!
For anyone who needs code to expose to blueprints, I made this function.
.h
UFUNCTION(BlueprintCallable, Category = "Online")
static bool GetControllerNetworkID(APlayerController* PlayerController, FString& ID, bool bAppendPort);
.cpp
bool UMyFunctionLibrary::GetControllerNetworkID(APlayerController* PlayerController, FString& ID, bool bAppendPort)
{
if (!PlayerController) return false;
if (!PlayerController->PlayerState) return false;
//ID = PlayerController->PlayerState->GetNetDriver()->LowLevelGetNetworkNumber();
ID = PlayerController->PlayerState->UniqueId->ToString();
if (!bAppendPort)
{
FString null;
ID.Split(FString(":"), &ID, &null, ESearchCase::IgnoreCase, ESearchDir::FromEnd);
}
return true;
}
Thanks for the share TK-Master! Any advice on how to implement this? Is this added to the game project source? I dont have alot of c++ experience with UE4 sry
Hi, I have 2 questions, kind of new to UE:
1- Where should be safer to add this MyPlayerState class? or MyGameMode? or it dont matters?
2- So due it is pulling the UniqueNetID from online subsystem, does it means that if I connect/play the game using steam I will get my steam ID but if lets say I play using PS4 I get my PS Network id instead? and if so, what happen if I play LAN mode, I will start getting 256 for player A, 257 for player B etc?
Thanks in advance.
Here is a video on how to get the Steam Player ID via blueprints if that helps.
CSteamID from Player State
Dear Everyone,
If what you want is specifically the CSteamID here is how you can get it from just the Player State ptr as an input!
if(PlayerState)
{
**CSteamID TheSteamifiedPlayerID(*(uint64*)PlayerState->UniqueId->GetBytes());**
}
Probably will need these includes:
#include "steam/steam_api.h"
#include "steam/isteamuser.h"
#include "steam/isteamutils.h"
So what this code lets you do is, given any PlayerState, retrieve the already replicated UniqueID and convert Steam Platform-specific ID
Enjooooy!
Rama
not fully understand how I can get these includes wich rama was defined (instead i use Steam OSS)
so… i tried to convert, but my code not works correctly(incorrect convertion)
TSharedPtr<const FUniqueNetId> pid = ion->GetIdentityInterface()->GetUniquePlayerId(PlayerControllerId);
if (pid->IsValid())
{
//variables
FString gz_pid = pid->ToString();
uint64 iSteamId = FCString::Atoi(*gz_pid);
FString gz_SteamId = "STEAM_"; // STEAM_X:Y:Z
// convertion
uint8 universe = (iSteamId >> 56) & 0xFF;
if (universe == 1)
{
universe = 0;
}
gz_SteamId += FString::FromInt(universe) + ":";
uint8 accountIdLowBit = (iSteamId & 1) & 0xFF;
gz_SteamId += FString::FromInt(accountIdLowBit) + ":";
uint32 accountIdHighBits = (iSteamId >> 1) & 0x7FFFFFF;
gz_SteamId += FString::FromInt(accountIdHighBits);
//result
return gz_SteamId;
}