I need the Steam ID for persistance of character through the Database. I built a C++ FunctionLibrary for blueprint use but it gives me my local computer name. Even if i create a session it stays the same. I did a bunch of searching and either solutions i found didnt work or got me only to this step.
Oh you want the Steam account ID; I don’t know how to get that, don’t even know if Valve allow you to read that.
I’d check Steam SDK and try to find some light
would love to use it except SteamUser() is undefined it says and wont compile. Apparently even though steam is running i need to do something to actually get access to the API?
You get just an undefined or unresolved externals? For both cases, try including **“ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h” **in your main game header file or somewhere else. Also make sure you added Steamworks to the build rules, so your build file should look something like this:
public class Steam : ModuleRules
{
public Steam(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });
//Steam stuff here
PublicDependencyModuleNames.AddRange(new string] {
"OnlineSubsystem",
"OnlineSubsystemUtils",
"Steamworks"
});
DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
PrivateDependencyModuleNames.AddRange(new string] { });
thank you mine was missing “steamworks” added it to look like this:
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class MGame : ModuleRules
{
public MGame(TargetInfo Target)
{
MinFilesUsingPrecompiledHeaderOverride = 1;
bFasterWithoutUnity = true;
PublicDependencyModuleNames.AddRange(
new string] {
"Core",
"CoreUObject",
"Engine",
"InputCore",
"RHI",
"UMG", "Slate", "SlateCore"
}
);
PublicDependencyModuleNames.AddRange(new string] {
"OnlineSubsystem",
"OnlineSubsystemUtils",
"Steamworks"
});
DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
}
}
Added the .h you gave me to the top of my blueprintlibrary .cpp file and BAM no more issues, i love you! now to figure out the rest of what i need to do
Glad I could help! I had the same problem as you a month ago and i couldn’t find help so the future can read this i also made a Wiki entry about the Steam Workshop, if you need something like this:
So, not to push the luck too far, i have a unique id seemingly appearing but it doesnt in any way match my Steam UID. Using Code:
FString UMyServerBlueprintLibrary::GetSteamID(APlayerController* PlayerController) {
FString ID = "";
int PUID = 0;
if (!PlayerController) return "Error";
if (!PlayerController->PlayerState) return "error";
if (SteamUser() == nullptr)
return "None";
CSteamID uid = SteamUser()->GetSteamID();
uint64 pid = uid.ConvertToUint64();
ID = FString::FromInt(pid);
return ID;
}
It gives me a number that is no where near long enough nor starts with the right digits.
Any ideas on this?
The odd thing is if i find my UID through a steamid finder it shows that number as the number CS:S would use…
according to what i can find this is a “Legacy ID”.
And now magically after changing nothing i get a nullptr from the steamuser(). No matter what i do its like steam isnt even running anymore. It was working fine last night, o started working on the DB connection and need the UID to check for existing players or not and the UID is nullptr now…
yea its wierd, magiacally its working again… maybe a ue4 glitch? lol. this is in standalone with the overlay displayed. Didnt work for a good while, then like magic it started working again…
Think im going to have to drop steam for now… nullptr yet again, 2 days straight this time, restarting steam or computer not fixing anything. not initializing again
nevermind, foudn the issue i think. dont knwo why it would of worked at all now that i think about it. The intermittent thing had me thrown for a loop. it was checking a steam user before init… stupid mistake on my part.
if (SteamAPI_Init()) {
if (SteamUser() == nullptr)
return "nullptr";
CSteamID steamID = SteamUser()->GetSteamID();
uint64 Return = steamID.CSteamID::ConvertToUint64();
//Return ID as String if Found
return FString::FromInt(Return);
}
return "Unknown";
}
Fixed it by putting the null pointer check inside the if(SteamAPI_Init())