Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • Bugs /
avatar image
Question by Vladimir Razumov · Sep 19, 2019 at 08:42 PM · CloudScriptentities

currentPlayerId is different with every entity cloud script call

PlayFabCloudScriptAPI.ExecuteEntityCloudScript(new ExecuteEntityCloudScriptRequest()
    {
        FunctionName = "TestId",
    },
    (res) =>
    {
        Debug.Log(res);
    },
    res =>
    {
        Debug.Log(res);
    });
handlers.TestId = function (args, context)
{
  var entityProfile = context.currentEntity;  
  log.info(currentPlayerId);
  log.info(entityProfile.Entity);
}

First - my client (Unity) code. Second - my cloud script function. entityProfile.Entity is the same every call (it's my entity), but currentPlayerId -is different all the time and belongs to another random player.

Comment

People who like this

0 Show 3
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Sep 20, 2019 at 09:18 AM 0
Share

When a player creates a player account, a master player account will be firstly created, then according to the title, a title player account under this master player account will be created. It means a player will have 2 ID. Title ID is unique in a title, master player ID is PlayFab ID, which is studio-unique.


When you make use of entity IDs, please also refer its entity type. If you review the full response of login APIs, both master account ID(PlayFab ID) and title ID are returned.

avatar image Vladimir Razumov SethDu ♦ · Sep 20, 2019 at 10:16 AM 0
Share

I understand this, but how is it connected with my question? When I call

PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
    {
        FunctionName = "TestId",
    },
    (res) =>
    {
        Debug.Log(res);
    },
    res =>
    {
        Debug.Log(res);
    });

I receive log where currentPlayerId is always my playfabId. And when i use ExecuteEntityCloudScript function currentPlayerId is different every call. I call those function being logged.

avatar image SethDu ♦ Vladimir Razumov · Sep 23, 2019 at 01:48 AM -1
Share

I have tested your code, if I directly print out currentPlayerId, it will throw a not-defined error and if it is context.currentPlayerId, this parameter is blank.

Have you set a global variable in your script?

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Vladimir Razumov · Sep 26, 2019 at 04:04 PM

I didn't define currentPlayerId by myself. it's a global variable, that described for example there https://api.playfab.com/documentation/server/method/ExecuteCloudScript . There is no api documentation for ExecuteEntityCloudScript from client, but I assume that this variable should be defined by server too. I don't know about context.currentPlayerId. I did not see mentions in docs and tutorials. Your test's results are very strange and looks like another bug as well.

Comment

People who like this

0 Show 3 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Sep 27, 2019 at 02:33 AM 0
Share

May I have your title ID and revision number?

avatar image Vladimir Razumov SethDu ♦ · Sep 27, 2019 at 10:15 AM 0
Share

4F51, last revision(217)

Right now in some functions currentPlayerId is defined from args. But currently I don't use those functions. And TestId functions results is always random with these functions in revision and without.

avatar image SethDu ♦ Vladimir Razumov · Sep 30, 2019 at 06:31 AM 0
Share

I have written a testing project to call ExecuteEntityCloudScript in a loop and the result is in the most of the case, it returns not-defined error and there are 1-3 cases return the correct ID every 20 times. We assume it to be a potential bug and will file it. I will keep you informed when there is feedback from our team.

PS. execute cloud script API will return success in most of the cases because the execution action is done successfully meanwhile even error is returned in the function, the status for API is successful, hence, we may need to check what is inside the onSuccess callbacks.

avatar image

Answer by Jacky Chou · Apr 06 at 03:23 AM

@SethDu @Vladimir Razumov

Hello, I am having the same problem. currentPlayerId is different every time the same client call a legacy cloudscript entity function. How was this problem solved?

Title id: B3B88. Revision: 1225

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Jacky Chou · Apr 06 at 03:26 AM

It seemed only happen in live revision

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    GetObjects/SetObjects InternalError 1 Answer

    CloudScript execution API requests issued (triggered action)), bug or how does it works? 1 Answer

    title_player_account PlayFabId does not work with cloud script 1 Answer

    CloudScript executed from Player dashboard returns unreadable response 1 Answer

    CloudScript won't deploy last revision 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges