I’m not sure how many players you’re showing in the top leaderboard, but I’m going to assume 100 (because it’s simple).
Here’s what I’m thinking: When a player has the number updated, it will be saved in the ODS. If this player is the top player, the server should fetch all top 100 entries. With these entries, it should check if any of them are closing up to the max-number. If they are closing up, it should divide all the entries by a set number, and update them. Now, you’ve fixed the problem of dividing it.
But, what if someone else gets their number increased? (I will be talking about the number as money from this point…). If you were to insert someone in the “top ODS”, you don’t know what to divide their money on? There’s a simple fix for this. Whenever you divide the top players’ money, you should save the number to divide it with in the database.
Moving on to how this works:
Example 1, reaching the limit
Let’s say you have 3 players in your leaderboard, which will look something like this
They are now approaching the max number, which is 10,000,000. The server should now divide all numbers with a number, for example 1,000,000. This would result in the players getting the following money:
But wow, they just lost all their money! No, because if you save the number you divided the money on, you know what to multiply the numbers with in order to display them.
Example 2, new player reaches the leaderboard
Now, let’s say we still have the 3 same players in our table, with the money divided:
And, let’s assume Joanna just got 8,300,000,000 money. The server will then divide the money by the number saved in the database. This will make the number become 8300. Now, she’s #3 in the leaderboard and it’s easy.
EDIT: Yes, there is an issue with this method. Stupid decimals. But one step at a time.
The best solution for you, would be to simply use an external database service where you can easily sort the top values!