Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnUserStatsReceived getting wrong appid #766

Open
Sambo3975 opened this issue May 8, 2024 · 0 comments
Open

OnUserStatsReceived getting wrong appid #766

Sambo3975 opened this issue May 8, 2024 · 0 comments
Assignees

Comments

@Sambo3975
Copy link

Describe the bug
I know that SteamUserStats.OnUserStatsReceived callbacks can pick up responses for other Steam apps. That's not the issue that I'm having. When I receive a callback, the appID received never matches my game's appID, even if the stats I received are the ones for my game.

To Reproduce
Steps to reproduce the behavior:

  1. Call SteamClient.Init(my_app_id)
  2. Add a callback to SteamUserStats.OnUserStatsReceived
  3. Call SteamUserStats.GetCurrentStats()
  4. When the callback is received, appID is always different from my game's appID, even for a response that is clearly for my game (Achievements match the ones I defined on the Steam partner page).

Calling Code

    // GameControllerSpawner.Awake
    void Awake()
    {
        // Attempt to connect to Steam
        try
        {
            SteamClient.Init(2258130);
            Debug.Log("Successfully connected to Steam client.");
            GameController.steamClientInitialized = true;
        }
        catch (Exception e)
        {
            Debug.Log($"Could not connect to Steam client: {e.Message}");
        }

        // Spawn the Game Controller
        if (GameController.Instance == null)
            Instantiate(gameController);

        Destroy(gameObject);
    }

    // GameController.Awake
    void Awake()
    {
        // ... Irrelevant other initialization code ...

        if (steamClientInitialized)
        {
            Debug.Log("Requesting Steam user stats.");
            SteamUserStats.OnUserStatsReceived += OnUserStatsReceived;
            SteamUserStats.RequestCurrentStats();
        }
    }

    // GameController.OnUserStatsReceived
    public void OnUserStatsReceived(SteamId appID, Result result)
    {
        Debug.Log($"Received stats for appid {appID.Value}; result = {result}");

        // if (appID.Value != SteamClient.AppId.Value) // Ignore stats received for other Steam apps.
        //     return;
        
        if (result != Result.OK) // Make sure query was successful.
        {
            Debug.LogWarning($"Failed to get user stats with status {result}.");
            return;
        }

        Debug.Log("Received Steam user stats.");

        var builder = new StringBuilder("The following achievements are available:");
        foreach (var ach in SteamUserStats.Achievements)
            builder.Append($"\n{ach.Name}");
        Debug.Log(builder.ToString());
    }

Expected behavior
Callback for my game's stats has an appID that matches the appID of my game.

Desktop (please complete the following information):

  • OS: Linux Mint 21.3 Cinnamon
  • Unity: 2021.3.33f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants