Implementing Steam c++ command as a blueprint node

I can’t find an example anywhere of exactly the right way to implement a Steam c++ command into an all BP project as a BP node. There’s broad documentation scattered about but nothing specific enough. Really the one I need to figure out the most is this:

bool BIsDlcInstalled( AppId_t appID );

Here’s the documentation with the command I’m trying to call:

https://partner.steamgames.com/doc/api/ISteamApps#BIsDlcInstalled

I’ve been banging my head on my desk for over a week now trying to figure this out. My extremely limited c++ knowledge isn’t making it any easier either.

The Steam overlay is set up and working fine (after altering the defaultengine.ini) along with achievements and leaderboards (through blueprint nodes).

This one explains it a little bit but I’m still missing something.

Any help on this is greatly appreciated, thank you.

Sorry you’ve had so much frustration. It’s a constant state for UE4 developers cuz there’s always something you don’t understand.

Anyway, the easiest thing to do is to use a C++ base class for the blueprint you need to call this Steam function from.

So your blueprint is derived from X (like AActor or APawn). You want to create a C++ class derived from that same class. Then you want to create a UFUNCTION() that is “BlueprintCallable” and call the Steam C++ functionality from there. On the other side, you want to reparent your blueprint to your C++ class. Now you can call your C++ function from your blueprint (you get a new node to use).

If you need the function to be called from multiple classes then you can put the UFUNCTION() in your GameMode. The static version of UFUNCTION)() can be called without requiring the GameMode object. Static functions don’t have to be in the GameMode but it’s where I put mine cuz it’s sort of global in a sense. Or maybe the GameMode is where you want to call it from, which works out just like if it was an AActor (i.e. same as the steps above)

If you need details, feel free to ask further.

Thank you so much for this. I had to walk away from it for a while to let things soak in and have made it most of the way. The game mode has been successfully re-parented to a c++ game mode class. I successfully created a blueprint node (blueprint pure text) using this guide:

I’m having trouble setting up the code to retrieve the Steam bool function result.

bool BIsDlcInstalled( AppId_t appID );

Here’s what my .h looks like:

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "GameMode_DLC.generated.h"

/**
 * 
 */



UCLASS()
class MYGAME_API AGameMode_DLC : public AGameModeBase
{
	GENERATED_BODY()

		UFUNCTION(BlueprintPure, meta = (DisplayName = "Hello World", CompactNodeTitle = "HelloWorld", Keywords = "String Hello World"), Category = Game)
		static FText HelloWorld();
			
};

This is my .cpp file:

#include "GameMode_DLC.h"

FText AGameMode_DLC::HelloWorld()
{
	return FText::FromString("Hello World");
}

This is what it looks like before I swap out ftext with the bool function.

Here’s my attempt at inserting the steam function:
.h file

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "GameMode_DLC.generated.h"

/**
 * 
 */



UCLASS()
class MYGAME_API AGameMode_DLC : public AGameModeBase
{
	GENERATED_BODY()

		UFUNCTION(BlueprintPure, meta = (DisplayName = "DLC 1", CompactNodeTitle = "DLC1", Category = Game)
		static bool BIsDlcInstalled( AppId_t appID );
			
};

.cpp file

#include "GameMode_DLC.h"

bool AGameMode_DLC::BIsDlcInstalled()
{
	return bool::FromString("DLC 1");
}

Try this

UFUNCTION(BlueprintCallable, BlueprintPure, meta = (DisplayName = "Hello World", CompactNodeTitle = "HelloWorld", Keywords = "String Hello World"), Category = Game)

(Tip: next time, use the “Code block” markup in the toolbar so the code you post is more readable)

Hi thanks for your reply. I accidentally posted it before I was finished and it should be formatted better now.

Much nicer. Yeah, so BlueprintPure is a modifier, not its own thing. You need BlueprintCallable as well.

Oh interesting. If you just do Pure it’s essentially a Get function and shows up like a variable. Didn’t know that. But if you want to pass in parameters, add the Callable one.

So it works with the ftext however I’m having trouble getting it to work with a bool. Something’s off since it’s failing to build. The code is in the second half of my since updated post. Thanks!

What is bool::FromString() supposed to do? You want to check the steam system, get the state and then return either true or false.

  1. You need a ) at the end of the UFUNCTION. You only have one there but there are two ( used.
  2. You have parameters in the function declaration but not the definition. Add the parameter “appID” to the function in the CPP file.
  3. Return either true or false based on some test. The FromString is way off. To see it compile, just have “return true;” in there.

UFUNCTION(BlueprintPure, meta = (DisplayName = “DLC 1”, CompactNodeTitle = “DLC1”, Category = Game))
static bool BIsDlcInstalled( AppId_t appID );
and

bool AGameMode_DLC::BIsDlcInstalled(AppId_t appID)
{
    return true;
}

Note: I replaced AppId_t with int to get it to compile. I assume you need to include a header to get that typedef defined. It may not be usable in a blueprint function though.

I don’t see it in the UE4 source. What’s that about?

Thank you for your continued patience and thorough responses. I wish I could answer your question, this is over my head.

It’s so close to working, but not quite there. The node shows up in blueprints correctly:

Problem is that it always returns as true. So hard to find an example of this somewhere but I’ll continue looking.

It always returns true because it says “return true;” in the function. We just did that as a first step. Now you need to use the Steam functions to detect if the DLC is there. If Steam says it’s there then return true. If Steam says it’s not there then return false.

It looks like you have to set up the Steam online subsystem in UE4 and then you can #include “isteamapps.h” to get access to BIsDlcInstalled(). AppID_t is just a uint32 so you can set up your blueprint node to take in a uint32 and give that to the BIsDlcInstalled() function. Get back the bool result and return it. Pretty straight forward. I think the hard part will be setting up Steam in the first place.

Finally, some advice: implementing your game for Steam is pretty advanced. Perhaps you should work on other aspects of the game to gain expertise and then go back to working with Steam. That said, I found this tutorial video which may help you: How to Setup Steam Multiplayer in Unreal Engine 4 Blueprints - Entire Guide - YouTube

Whatever you choose, good luck.

Thanks for your reply. Like I said before, already got Steam set up and working. It’s just this one c++ snip it that’s giving me trouble since the whole project is blueprints. I’ll try to dissect what you said to alter my code to do that.

Haven’t found that video yet too, looks helpful.

Ah. Sorry. I help lots of people so some of the details fall aside. In that case, it should be straight forward.

It’s alright, I really appreciate the help. Considering using an alternative method for DLC since my c++ knowledge is so limited. Here’s some errors I’m getting and my latest attempt at the code. It still needs to be fixed so it doesn’t always return true. It’s also having trouble accessing the isteamapps.h and appID_t is undefined:

.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "isteamapps.h"
#include "GameMode_DLC.generated.h"

/**
 * 
 */



UCLASS()
class MYGAME_API AGameMode_DLC : public AGameModeBase
{
	GENERATED_BODY()

		UFUNCTION(BlueprintPure, meta = (DisplayName = "DLC 1", CompactNodeTitle = "DLC1", Category = Game))
		static bool BIsDlcInstalled(appID_t appID);
			
};

.cpp

#include "GameMode_DLC.h"

bool AGameMode_DLC::BIsDlcInstalled(appID_t appID)
{
	return true;
}

Errors:

226055-compileerrors.jpg

The declaration error is line 19 in the .h

Just remember this is the blind leading the blind. I’ve never used Steam so I’m flying by Google. That video I linked probably has good info. That said, here we go:

First, you need to remove #include "isteamapps.h" and add these includes:

#include "ThirdParty/Steamworks/Steamv139/sdk/public/steam/isteamclient.h"
#include "ThirdParty/Steamworks/Steamv139/sdk/public/steam/isteamapps.h"

That may not be the cleanest way but I can’t find anything saying how to do it (had to go through the engine source).

Then, change the parameter type “AppId_t” to “uint32” of the blueprint function in both the h and cpp files. That should get it to compile.

Then you need to get the interface to the steam subsystem. Once you have that, you should be able to call Steam’s BIsDlcInstalled() and return the result you get. I’m not sure how to get the interface yet. Hoping you know that part already.

SteamApps()->BIsDlcInstalled;