Download

Issue Getting Steam UID

they must allow it… games like Arl use it for their account system as well.

SteamUser()->GetSteamID()->ConvertToUint64();
should do it

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 :slight_smile:

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 :smiley: 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.

a422302501d28728066ca5b9a7152c13213e4152.jpeg 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…

Do you see the overlay? Note that its not working in the editor.

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…

Hmm I think Steam is the problem… Sometimes it does not initialize, but if you go for production, it should work as expected

thanks 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 :frowning:

Hmm, strange. It means that steam is not ready, but if you see the overlay, Unreal fails some way to init Steam. Try wrapping your whole code inside



if (SteamAPI_Init())
{
  //your ID getting
}
else
{
  //you have a Problem
}


Now this 1. looks if steamAPI is initialized, and 2. inits it when not. I hope this works!

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())

Thats exactly what I was telling you :smiley:

Yea posted within a minute of each other haha, thanks again for watching this thread :slight_smile: would of sucked to take steam out since i would of had to put the account system back in that i completely deleted and used the steamID for.

No problem :slight_smile: If you have further problems, just tell 'em!

did you ever sort out dedicated servers and how to join them with steam? i have a thread in elsewhere but no one seems to have an answer. i have steam running, i get what i think is a good message from the server log…
e781f9a04d2c559eb5881f9802ab50df6a028b15.png

but i have no clue how to connect to it. i want it to be the only server to be connected to, i didnt want to have to search sessions (which i read may not work anyways) i just want to console command open to it… i tried
open ip:port
<mysteamid>:port

and neither seem to work.

going to try:



#include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_gameserver.h"


FString UMyServerBlueprintLibrary::GetServerSteamID() {

	if (SteamAPI_Init()) {

		//Return ID as String if Found
		return FString::FromInt(SteamGameServer_GetSteamID());
		);
	}

	return "Unknown";
}

but even if it works it will MAYBE give me the steam id of the server instance, but if it changes im going to be screwed lol.

So servers have the same SteamID as the user who hosts it? I’m not quite sure since I never done this, but you may check out this, because that topic seems to deal with server authentification…