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 /
  • General Discussion /
avatar image
Question by Vsevolod Metelskyi · May 20, 2019 at 02:42 AM · CloudScriptscheduled tasks

Alternative way of implementing energy restoration logic

I have run out of currencies amount limit but I still need to implement energy and regeneration logic for it. What I thought about is adding energy key to the player title data as a simple json value, writing a CloudScript that would receive players segment as an argument and then loop through all the players from that segment and add 1 to their energy value. And adding a scheduled task to run this script once per hour. Is it going to work with large amount of players (let's say 10 000 players in a segment)? Or am I going to get performance spikes or face API calls limit? How would this approach be different from using native PlayFab regeneration parameters from the Currencies tab?

And I also think that I could have a collision in this case.

For example if I have 10 points of energy and I run a level which subtracts 3 points and the abovementioned script executes at the same time and tries to restore 1 energy point, can I be sure to get 8 energy points after both of these operations are finished executing?

I fear that a situation like this could happen:

1. Energy subtraction script started, it gets current value which is 10.

2. Before subtraction script is completed, restoration script has started executing. It gets current energy value which is 10 as well.

3. If subtraction script will finish sooner, I will have 7 points, but if restoration script will finish sooner, I will have 11.

Is a situation like this could occur with a solution I have described above?

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by SethDu · May 20, 2019 at 09:00 AM

Your solution is feasible using Scheduled Tasks, and you should not interactively selecting players in the Cloud Script which will definitely exceeds the run-time limits. The energy points only depend on the order of recovery/consumption function and these functions should be asynchronous no matter it is called in Scheduled Tasks or directly runs in the client via ExecuteCloudScript API.

I don’t think you should concern too much on this. I am not sure what's the maximum number of the "energy", but there is always this problem when it is reaching the maximum.

Besides, this is a PlayFab built-in supported feature, if you keep using work around solutions, we cannot guarantee there is no potential issue in the future. Our suggestion is if you have specific needs that Essential Tier cannot cover, please contact our sales team via sales@playfab.com and we can customize your limits according to your needs.

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

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Is it possible to abort a scheduled task inside the CloudScript function? 1 Answer

    How to make cron jobs on Playfab? 1 Answer

    About the ranking schedule setting 1 Answer

    Need assistance with Unbanning players 1 Answer

    Scheduled Tasks Action Order 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