question

manolhsplaths46 avatar image
manolhsplaths46 asked

Why playfab is so complicated to learn?

Like seriously 5 days now i am trying to understand but no idea.


If you give this :

{
  "code": 200,
  "status": "OK",
  "data": {
    "Leaderboard": [
      {
        "PlayFabId": "10931252888739651331",
        "DisplayName": "username",
        "StatValue": 12,
        "Position": 0
      }
    ],
    "Version": 0
  }
}

How am i suppose to implement this code? no idea you can't just go

public myfunc(){
                
displayName :"username", Statvalue : "12"
}

There should be an example on how you should use them.

pff so confusing and disappointing... i never thought it would be so difficult. Everybody talked about playfab but yet i can't learn it if i don't ask people...

Yet people will response in 1 day so 1 question per day 7 questions answered per week there is no progress to understand this at all.

I just don't get it on how you should use it on login or register they put all parts of code like 30 lines of codes but they can't put 1 line to display on how to implement. pff

4 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.

Andy avatar image Andy ♦♦ commented ·

Could you clarify what you're trying to do? That looks like the response to a GetLeaderboard call, but I don't know what you want to do with it.

0 Likes 0 ·
manolhsplaths46 avatar image manolhsplaths46 Andy ♦♦ commented ·

i just want to know how to implement when i see this:

 
                   
  1. {
  2. "code":200,
  3. "status":"OK",
  4. "data":{
  5. "Leaderboard":[
  6. {
  7. "PlayFabId":"10931252888739651331",
  8. "DisplayName":"username",
  9. "StatValue":12,
  10. "Position":0
  11. }
  12. ],
  13. "Version":0
  14. }
  15. }
0 Likes 0 ·
Andy avatar image Andy ♦♦ manolhsplaths46 commented ·

How to implement what? That's a JSON blob. It's just data. What do you want to do with it?

Based on your other question tonight, I assume you're asking how, in Unity, you can receive a response from the GetLeaderboard API and then display the result to the user. Is that correct?

0 Likes 0 ·
manolhsplaths46 avatar image manolhsplaths46 commented ·
 
                  
  1. {
  2. "code":200,
  3. "status":"OK",
  4. "data":{
  5. "Leaderboard":[
  6. {
  7. "PlayFabId":"10931252888739651331",
  8. "DisplayName":"username",
  9. "StatValue":12,
  10. "Position":0
  11. }
  12. ],
  13. "Version":0
  14. }
  15. }
0 Likes 0 ·

1 Answer

·
Seth Du avatar image
Seth Du answered

If you want to get leaderboard data, you should use API calls in the Unity instead of directly catching http requests and responds, because what you received is json data.

The followings are a sample for getting leaderboard data:

// inport PlayFab SDK into your Unity Project
// first you have to login to change the state
PlayFabClientAPI.LoginWithCustomID(
    // the format of request is in the Documentation
    New LoginWithCustomIDRequest
    {
        CustomId = "xxxxxxx",
        TitleId = "xxxx",
        CreateAccount = true
    },
    
    OnSuccessCallback =>
    {
        PlayFabClientAPI.GetLeaderboard(
            new GetLeaderboardRequest
            {
                StartPosition = 0,
                StatisticName = "your_data"
            },
            OnSuccess => 
            {
                List<PlayerLeaderboardEntry> data = OnSuccess.Leaderboard;
                foreach (PlayerLeaderboardEntry item in data)
                {
                    // this will print your display name with the position
                    print(item.DisplayName+": "+item.Position);
                }
            },
            OnFailure => 
            {
                print("fail to get leaderboard");
            });
    },
    OnFailureCallback =>
    {
        print("fail to login");
    }
);

And for the success and fail callback, you can always define your own function. The usage of API calls are pretty similar.

According your previous question, to list all data in unity UI, it's better to generate text labels dynamically via prefabs, and set different offsets for each of label.

10 |1200

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

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.