Giving Users Time-Based Rewards

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I have a monthly leaderboard in my game, and I want to give users an award at the end of the month if they are #1, #2 or #3.

  2. What is the issue? Include screenshots / videos if possible!
    Each server in the game has a script that uses an OrderedDataStore to update the leaderboard in that particular server. My plan was to get the top 3 players when the month ends and update their DataStore to have the reward. The issue is that every active server will run this code when the month ends and cause a DataStore overload.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did research online and asked around, but I didn’t find anything.

1 Like

Hello, to get rid of the DataStore overload you can implement a centralized leaderboard system. If this solution does not work of if you need more details than ask.

1 Like

Hello! I’m making the same system and I came across the same problem. Can you help me with that?

This is a tricky situation. What you’re describing isn’t exactly a “DataStore overload” but a race/timing issue. Since every server will try to reward the top players at the same time, each server can wait a random delay large enough to prevent multiple servers from hitting the DataStore simultaneously. Use a "rewarded” flag or key in the global DataStore so only the first server that checks proceeds to update it. The flag can be reset at the start of the new month, well within the random reward delay period.

1 Like

This is a good idea. I improved it by making it all happen on Memory Store. Because it’s a faster solution. So when the month ends, each server will call an updateAsync with for example ttl = 60s to the MemoryStore then if not saved then save top players. Thanks for reply.

When the player joins, check whether they’re top 3, the end of the month has passed, and check data “collectedMonthlyReward”. I think that’d be the most viable solution compared to having every server racing to set their data.

What if player join after new month?

Every month, set collectedMonthlyReward to false. It’s a bit more than that though - You’d have to store some other data, but nothing too difficult.

I will hit this issue in one of the games I’m developing, and this is what I was thinking would solve that. The only downside is if two servers somehow pick the exact same time to check the flag. A whole day should cover that, but not totally 100%.. there still would be a ultra thin chance that could happen. In that case it would be very slim chance more than two did that. So this needs a bit more thinking it out just to cover a one in million chance..

With UpdateAsync never. You can check docs.

1 Like

The player data isn’t a part of the global key the server checks for the end-of-month win flag.
I haven’t started working on this yet; it is still a theory at this point. I know I use a separate DataStore to track the end-of-month reset. I was thinking this could be added to that.

My other thought was to have a pickup point where the winnings could be collected.
This reduces simultaneous writes to the DataStore, since the server only sets the “available” flag.
It avoids collisions completely because players trigger the reward claim individually.
It makes it easier to handle cases where multiple servers are active at month-end.

Somebody has had to run into this before; it would be interesting to see their solution.
Myself I just have theories of what may work.

1 Like