question

Opticgamer avatar image
Opticgamer asked

How to get a players vc using their player ID without using static classes?

Hello, I was using the "LoginWithCustomID" function but I realized that this function doesn't let you get the players vc using the PlayerID. So how do I get the players currency using their playfab account id instead of using a custom ID? I saw the tutorial but the big problem is that it uses static classes. Can anyone provide a proper way to get a certain virtual currency without customids or static classes using the Player IDs? Would be great if a code sample could be provided.
apissdks
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.

Ivan Cai avatar image Ivan Cai ♦ commented ·

Firstly, the customid must be defined in the properties of the LoginWithCustomID API. If not, it won't login successfully. What does "My problem is that it won't log in using the custom id" mean?

0 Likes 0 ·
Opticgamer avatar image Opticgamer Ivan Cai ♦ commented ·
I realized that I was using the wrong function so I have updated my question. I want to be able to get player vc's without using CustomID or Static classes.
0 Likes 0 ·

1 Answer

·
Ivan Cai avatar image
Ivan Cai answered

The customid only serves as a credential for anonymous login. The player id is a string that marks the player's account. In any case, you should first determine which way the player logs in. After the player successfully logs in, then call the GetUserInventory API to obtain the player's VC. You can refer to our official doc PlayFabSample to implement function.

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.

Opticgamer avatar image Opticgamer commented ·

I've never heard about this PlayFabSample I was always linked to the unicorn game that used static classes, thank you.

0 Likes 0 ·
Opticgamer avatar image Opticgamer commented ·

I'm getting an error saying:

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <437ba245d8404784b9fbab9b439ac908>:0)
CDisplay.UpdatePlayerInventory (PlayFab.ClientModels.GetUserInventoryResult result) (at Assets/TFSB/Scripts/CDisplay.cs:29)
PlayFab.Internal.PlayFabHttp+<>c__DisplayClass23_0`1[TResult].<_MakeApiCall>b__1 () (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:217)
PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:247)
UnityEngine.Debug:LogException(Exception)
PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer) (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:251)
PlayFab.Internal.<Post>d__12:MoveNext() (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:190)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
0 Likes 0 ·
Ivan Cai avatar image Ivan Cai ♦ Opticgamer commented ·

Can you provide reproduce steps?

0 Likes 0 ·
Opticgamer avatar image Opticgamer Ivan Cai ♦ commented ·
I got it working I didn't realize that my vc name was wrong. Thank you for the help :)
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.