question

yzx2002 avatar image
yzx2002 asked

How to keep login in different scenes?

I make a login scene and it works fine. And then I click play button to go to a gameplay scene. In gameplay scene I wrote code to execute cloud script, but it failed. Is it because I lost my login status?

error:

PlayFab.ClientModels.ScriptExecutionError -- The script called a PlayFab API, which returned an error. See the Error logs for details. UnityEngine.Debug:LogError(Object) Ingredient:OnGetThisIngredientCallback(ExecuteCloudScriptResult) (at Assets/Scripts/GameObjects/Ingredient.cs:132) PlayFab.Internal.<MakeApiCall>c__AnonStorey1A`1:<>m__28() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:165) PlayFab.Internal.<MakeApiCall>c__AnonStorey1B:<>m__29(String) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:126) PlayFab.Internal.<Post>c__Iterator7:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:200) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

CloudScript
1 comment
10 |1200

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

yzx2002 avatar image yzx2002 commented ·

my cloudscript :

handlers.PlayerGetItem = function(args) {


     var itemId = args.ItemID;
     var grantItem = server.GrantItemsToUser({
        PlayFabId: currentPlayerId,
        ItemIds: [itemId]
      });
 }

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

No, if you're able to call a Cloud Script at all, you have a current Session Ticket. In this case, what specifically are you passing in for the ItemID? One thing I'd recommend is using try/catch to capture any issues with calling into Server API methods, so that you can return additional context to the calling client.

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

yzx2002 avatar image yzx2002 commented ·

I passed a string of itemID. What I want to do is that the player find the item in the client, and then grant the item to his account in the server.

0 Likes 0 ·
brendan avatar image brendan yzx2002 commented ·

Yes, that's what the GrantItemsToUser call will do. What is the Title ID for your test, and what ItemID are you passing in to this call?

0 Likes 0 ·
yzx2002 avatar image yzx2002 brendan commented ·

Finally I found that I make a type ItemId in client part.

But the log show nothing about this error. I used try/catch but also got no log about any error.

What's the best way to debug cloud script? Thank you!

0 Likes 0 ·
Show more comments
avimon avatar image avimon commented ·

@Brendan I am using Playfab with photon. I have logged into playfab and authenticated it with photon. I just want to ask if I move to next scene will I still be loggedin to my playfab account or connection will be closed? Please help me !

0 Likes 0 ·
brendan avatar image brendan avimon commented ·

The PlayFab login is unaffected by anything you do with Photon. The Session Ticket you get back on login is currently valid for 24 hours.

1 Like 1 ·

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.