# Issue Getting Steam UID

**URL:** <https://forums.unrealengine.com/t/issue-getting-steam-uid/54028>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 31, 2016, 2:06am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028 "2016-01-31T02:06:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 2:06am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/1 "2016-01-31T02:06:44Z")

</div>

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.

![6e56b06e4bc7bd52fbbe9a3cb7d0fa2d48305ba5.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

 ![c5a8c046d3.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/4/e4920840b391d946d9b7dbd2328b006fd0bf47a3.png)

```auto

FString UMyServerBlueprintLibrary::GetSteamID(APlayerController* PlayerController) {

	FString ID = "";

	if (!PlayerController) return "Error";
	if (!PlayerController->PlayerState) return "error";

	ID = PlayerController->PlayerState->UniqueId->ToString();

	return ID;
}

```

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [January 31, 2016, 2:48am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/2 "2016-01-31T02:48:55Z")

</div>

PayerState-\>PlayerId

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 2:56am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/3 "2016-01-31T02:56:39Z")

</div>

That gives me a tiny number… 256 on first run then when i create a session it increments to 257 but not the actual steam ID.

```auto

FString UMyServerBlueprintLibrary::GetSteamID(APlayerController* PlayerController) {

	FString ID = "";
	int PUID = 0;

	

	if (!PlayerController) return "Error";
	if (!PlayerController->PlayerState) return "error";

	PUID = PlayerController->PlayerState->PlayerId;
	ID = FString::FromInt(PUID);

	return ID;

}

```

Connected to Steam as the Dev App

 ![2ff561026b.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/9/5977ea459c399e8bcc602d371ad43bef99057cf8.jpeg)

New ID:  
 ![c82ecdeaee.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/7/67a4e706638bb5f7cc764cf26eb461e47840a913.jpeg)

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 6:03am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/4 "2016-01-31T06:03:26Z")

</div>

Cant Get any sort of connection to Steam API Functions in VS either…

CSteamID uid = SteamUser()-\>GetSteamID(); has CSteamID, SteamUser() and GetSteamID() As Unidentified…

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [January 31, 2016, 9:16am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/5 "2016-01-31T09:16:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 2:06pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/6 "2016-01-31T14:06:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![iUltimateLP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iUltimateLP](https://forums.unrealengine.com/u/iUltimateLP)\
**Post date:** [January 31, 2016, 5:39pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/7 "2016-01-31T17:39:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 5:48pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/8 "2016-01-31T17:48:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![iUltimateLP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iUltimateLP](https://forums.unrealengine.com/u/iUltimateLP)\
**Post date:** [January 31, 2016, 5:53pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/9 "2016-01-31T17:53:09Z")

</div>

> [@Vindomire;464793](#):
>
> 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:

```auto

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] { });

```

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 7:14pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/10 "2016-01-31T19:14:49Z")

</div>

thank you mine was missing “steamworks” added it to look like this:

```auto

// 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 🙂

---

<div class="post-metadata">

**Author:** ![iUltimateLP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iUltimateLP](https://forums.unrealengine.com/u/iUltimateLP)\
**Post date:** [January 31, 2016, 7:38pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/11 "2016-01-31T19:38:57Z")

</div>

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:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [January 31, 2016, 10:05pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/12 "2016-01-31T22:05:11Z")

</div>

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:

```auto

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](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png) 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”.

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [February 4, 2016, 1:05am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/13 "2016-02-04T01:05:32Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![iUltimateLP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iUltimateLP](https://forums.unrealengine.com/u/iUltimateLP)\
**Post date:** [February 4, 2016, 3:49am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/14 "2016-02-04T03:49:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [February 4, 2016, 5:45am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/15 "2016-02-04T05:45:32Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![iUltimateLP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iUltimateLP](https://forums.unrealengine.com/u/iUltimateLP)\
**Post date:** [February 4, 2016, 6:36am UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/16 "2016-02-04T06:36:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [February 4, 2016, 1:43pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/17 "2016-02-04T13:43:11Z")

</div>

thanks again.

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [February 6, 2016, 5:52pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/18 "2016-02-06T17:52:32Z")

</div>

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 ☹

---

<div class="post-metadata">

**Author:** ![iUltimateLP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iUltimateLP](https://forums.unrealengine.com/u/iUltimateLP)\
**Post date:** [February 6, 2016, 6:10pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/19 "2016-02-06T18:10:05Z")

</div>

> [@Vindomire;468656](#):
>
> 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 ☹

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

```auto

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!

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [February 6, 2016, 6:11pm UTC](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028/20 "2016-02-06T18:11:05Z")

</div>

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.

```auto

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

[Next page](https://forums.unrealengine.com/t/issue-getting-steam-uid/54028.md?page=2)
