question

Stefan Francesco Federico avatar image
Stefan Francesco Federico asked

GetUserDataResult Doesnt get data.

Hi, I'm making a Multiplayer FPS Game, right now I'm trying to save bought weapons to Playfab using Player Data (title).

Issue is: It doesnt get all or sometimes doesnt even try to get the weapons.

It says i have them on Playfab, but when i'm in the game it says i dont have it.

Request Code:

        for (int i = 0; i < mm.gameInformation.allWeapons.Length; i++)
        {
            PlayFabClientAPI.GetUserData(new GetUserDataRequest(), cs.weaponload, cs.ondatafail);
            cs.weaponid = i;
        }

Result Code:

    public void weaponload(GetUserDataResult result)
    {
        Debug.Log(result.Data.Keys);
        if (result.Data.ContainsKey(gameinfo.allWeapons[weapon].weaponName))
        {
            gameinfo.allWeapons[weapon].wasboughtornot = true;
        }

    }
}

I'm using Unity 2021.1.22f1

Player DataTitle Datadata
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

May I know more details about “save bought weapons to Playfab”? When is the API called? To be clear, when you frequently update and read, shared resources will have latency to sync . As you have hosted multiplayer servers for your game, you may cache the data on the server and upload the eventual data to PlayFab when the game has finished. PlayFab, as it is based on RESTful API, is more suitable for rear-time game, since you have deployed server for your FPS game, there is no need to frequently update data via PlayFab during the game. It is recommended to only do verification for data that won’t change in the game.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Stefan Francesco Federico avatar image Stefan Francesco Federico commented ·

“save bought weapons to Playfab” Means the weapon name gets saved in player data (Title), then it will have 2 values (False or True). to know if the player has the weapon bought or if they have sold it.

Oh and also it doesnt to it during game, only in the main menu in which people can buy weapons in the section "Shop"

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Stefan Francesco Federico commented ·

Sorry for the late response. According to recent testing, I cannot reproduce this issue. My suggestion is to output logs for the value in "gameinfo.allWeapons[weapon].weaponName" and output the "result.Data.Keys" at the same time.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.