question

zomb avatar image
zomb asked

Flag of running Scheduled Task

Hi! I want to use Scheduled Task for my own implementation of leaderboard refresh. In function will be calculation and update some statistics and info fields, adding reward. But I want to know somehow, what right now running this process and I shouldn't change player's points. If there no function like this, maybe there some way to run one script before start of mass function and more important - after? Because main question - when this process is finished. Then there can be way to set/remove flag in title data.

10 |1200

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

brendan avatar image
brendan answered

If I'm understanding your question, the best way to do this right now would be by using multiple statistics. That way, you could "lock" the leaderboard, so that all new writes go to a "current" leaderboard, while you're updating players for the previous leaderboard values.

Alternately, we'll be updating later this quarter with additional leaderboard functionality, which will allow for more complex behaviors, including rewards for players based upon their position in a leaderboard at the time it resets.

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

zomb avatar image zomb commented ·

Hi Brendan. Yes, I will use another statistic field in time of processing results. But question is - How to know, what scheduled task running right now? As I see in "limits" - it will process 10 users/s, so all process can take some minutes. Today I found com.playfab.title_started_task and title_completed_task events in "rules" tab. Will it be trigged by sheduled task? If so, I can set flag in title data at start of task and remove it at its end.

About "additional leaderboard functionality". Will we can to launch cloudscript for each user at the time of reset?

0 Likes 0 ·
brendan avatar image brendan zomb commented ·

Title events cannot trigger Rules - only player and custom events can, right now. Also, please bear in mind that a) there will be a slight delay between when the task starts and when the event is processed, and b) Title Data is cached, so from when it is updated there will be a short period of time during which the old value may be returned.

We are working out the details of the leaderboard update, and we'll be sharing more info on this as soon as we can.

0 Likes 0 ·
lanpartygamesstudio avatar image lanpartygamesstudio brendan commented ·

Hi Brendan. I was trying to trigger a cloudscript function with a rule listening for a title_completed_task event. I cannot find this event in the "rules" tab as Zomb says. What happened? Was it removed? How can I react to a scheduled task completion now?

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

How big dalays (a) and (b) can be?

0 Likes 0 ·
brendan avatar image brendan zomb commented ·

It's always possible that the Title Data cache time may change in future, but at the moment I would expect that the total delay would be less than a minute, max.

0 Likes 0 ·
zomb avatar image zomb brendan commented ·

Oh. Wow. For 1 minute can happens much of action. Can you suggest some other way to save variable just for server use in cloudscript?

And what about delay between start of scheduled task and rising of event?

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

What you mean by "switch" and "lock"? Version system? But I don't see, how connect it with cloudscript.

I was thinking this way:
1) user will call cloudscript, which will update some of his stats. It will read stat, increment it and write it back.
2) sheduled script will iterate all users and process their stats and finaly wipe it.
I'm affraid, what if (1) begins before reset of statistics and it ends after reset statistics it will write old big summ which I start to increment earlier.
I saw "Aggregation method" in leaderbord and I prefer method with automatic incrementation, but I need to set value of this stat manually in another point, so I can't use it.

0 Likes 0 ·
brendan avatar image brendan zomb commented ·

Sorry, I was thinking you wanted to have a system where you were tracking something like "current week's scores" alongside "previous week's scores", in which case you would be swapping which leaderboard you're using. If you're only using one, the simplest thing to do would be to put the time for your scheduled Task into the Cloud Script. That way, in addition to having a flag you can check to see if it's safe to write new statistics, you would also know that as of a certain time, it's not safe to write statistics even without checking the flag (to be safe, I would make it a few seconds before the scheduled start time, and up to one minute past the scheduled start time).

0 Likes 0 ·
zomb avatar image zomb brendan commented ·

>put the time for your scheduled Task into the Cloud Script.

Do you mean add it as constant to script and maintain that constant corresponding with sheduled task?

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

Thank you. I will try it.

0 Likes 0 ·
Falcon Land avatar image
Falcon Land answered

Not sure if i understand correctly what you need. So I just add my 2 cents. I would add protection for updating stats on client side. For example, you know that you will be executing the cloud script at 8 a.m. daily. So clients could be setup to know this time and prevent users from altering the player stats ( fro example disabling the button to go to PvP battles). This way you could be 99% sure that noone will mess with your statistics while you are executing the cloud script.

I am not sure if I understand your problem correcty, so hopefuly you will find this advice helpfull somehow :)

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.