Forum rules - please read before posting.

How to check if DLC owned on Steam?

I'm working on a DLC for my game, and I can include the dlc content to the base game, I would just like to have a simple button to play the DLC.

Pressing the button should check if the player owns the DLC, and then the game starts. If not, it should send the player to the steam page of the DLC where you could purchase it.

I have installed the steamworks plugin and got achievements working, so I just want to know how to integrate this check to a custom action in Adventure Creator.

Comments

  • For a simple "condition is met" / "condition is not met" Action that can run one of two options, create a new custom Action using the included ActionCheckTemplate.cs file as its basis.

    I can assist with this if you can share the code snippet of the check to make.

    An alternative to using a custom Action, though, would be to have the code snippet instead update a Global Boolean variable - see the Manual's "Variable scripting" chapter for details on how to update a variable's value through script.

  • This is what it says on the Steamworks documentation

    bool BIsDlcInstalled( AppId_t appID );

    Name - Type - Description
    appID - AppId_t - The App ID of the DLC to check.

    Checks if the user owns a specific DLC and if the DLC is installed

    Returns: bool
    true if the user owns the DLC and it's currently installed, otherwise false.

    Note: Should only be used for simple client side checks - not intended for granting in-game items.

  • You'd need a way of setting the appID variable. Searching the docs you've copied from suggests you can set it with an ID number. Something along these lines should do it:

    using UnityEngine;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    using Steamworks;
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionCheckDLC : ActionCheck
        {
    
            public override ActionCategory Category { get { return ActionCategory.Custom; }}
            public override string Title { get { return "Check DLC"; }}
    
            public int appID;
    
            public override bool CheckCondition ()
            {
                AppId_t myDlcId = new AppId_t(appID);
                bool hasDLC = SteamApps.BIsDlcInstalled(appID);
                return hasDLC;
            }
    
            #if UNITY_EDITOR
    
            public override void ShowGUI ()
            {
                appID = EditorGUILayout.DelayedIntField ("App ID:", appID);
            }
    
            #endif
    
        }
    
    }
    

    If it needs tweaking, it'll be a case of editing the CheckCondition function.

  • AC Version: 1.74.2
    Unity Version: 2019.4.18f1
    SteamworksNet: 15.0.1


    Hello. I tried adding the above script to my build, but I am receiving a couple errors in the console.

    ActionCheckDLC.cs(21,43): error CS1503: Argument 1: cannot convert from 'int' to 'uint'

    ActionCheckDLC.cs(22,53): error CS1503: Argument 1: cannot convert from 'int' to 'Steamworks.AppId_t'


    Line 21 = AppId_t myDlcId = new AppId_t(appID);

    Line 22 = bool hasDLC = SteamApps.BIsDlcInstalled(appID);

  • edited December 2021

    Try this:

    using UnityEngine;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    using Steamworks;
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionCheckDLC : ActionCheck
        {
    
            public override ActionCategory Category { get { return ActionCategory.Custom; }}
            public override string Title { get { return "Check DLC"; }}
    
            public int appID;
    
            public override bool CheckCondition ()
            {
                uint appID_u = (uint) appID;
                AppId_t myDlcId = new AppId_t(appID_u);
                bool hasDLC = SteamApps.BIsDlcInstalled(myDlcId);
                return hasDLC;
            }
    
            #if UNITY_EDITOR
    
            public override void ShowGUI ()
            {
                appID = EditorGUILayout.DelayedIntField ("App ID:", appID);
            }
    
            #endif
    
        }
    
    }
    
  • edited December 2021

    Hello. The error for Line 22 was resolved with your edit. Also added a " ( " to (appID);.

    The Line 21 error moved down to Line 22.


    ActionCheckDLC.cs(22,43): error CS1503: Argument 1: cannot convert from 'int' to 'uint'


    Line 22 = AppId_t myDlcId = new AppId_t(appID);

  • OK. I've tweaked the above - give it another go.

  • It works now, in Unity. I will test it, and give an update once I get everything on Steamworks.


    uint appID_u = (uint) appID); <- This line needed a " ( ".

    I added it here, and removed the space. Is this correct? -> uint appID_u = (uint)(appID);

  • edited December 2021

    Yes - sorry, that was a typo on my part. I've corrected it now.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.