Getting the position of a key in an OrderedDataStore

This idea came from another topic, where we couldn’t find the position of a specific key with ease.

So here is my proposal:

int GetOrderedPositionAsync(String key, boolean Reverse = false)
returns the int value of the position in the ordered datastore.

So for example if I had a shooter game with 100 different people in the ordered datastore, and it keeps track of kills, say my user is 21st in place for the most kills, I use that function to get his position, which should return 21.

Also Reverse is for tables that have the least, so for example you have a rating system where 1 is the best rating in the game, and 100 is the worst, then you can put Reverse as true and it will return the position according to the lowest values to highest.

46 Likes

I like your use case but I personally think it’s better to use :GetOrderedAsync() to show the user a range of scores. That way you get the data once and then query it for your info.

1 Like

But the whole point is say you’re in position like 1337, you can have a profile or something in game that people can see your position, without having too go through pages and pages to find yours.

4 Likes

Ah, that makes more sense. But really you should be caching data so that it would be a simple table lookup.

If anything, I believe a better suggestion would be to add a ‘GetCurrentPageNumber’ method to the Pages object. This would allow even more uses as the GroupService API also uses the Pages object.
Plus, that way, you would be able to use that and then use GetSortedAsync to achieve a similar result.

5 Likes

As nice as showing a position sounds, it’s not actually very useful or nice for the user. Sure, if you’re one of the top 100 or whatever users on the game, then you like it… but for the 99% of users playing your game, knowing that they’re in 14,679th place in the rankings isn’t very helpful or fun.

It’s kind of a missing feature, but there isn’t really any use for it other than exactly this, and I don’t think that this is that helpful to begin with, so I don’t know if it’s needed.

2 Likes

I see a use-case where if you’re better than rank 10000 you get a bonus. And 1000, and 100, like in the summer clan battles.

“But really you should be caching data so that it would be a simple table lookup.” <- may as well do that, though. If you’re giving out bonuses for ranks, you’d probably have a leaderboard somewhere anyway.

2 Likes

[quote] I see a use-case where if you’re better than rank 10000 you get a bonus. And 1000, and 100, like in the summer clan battles.

“But really you should be caching data so that it would be a simple table lookup.” <- may as well do that, though. If you’re giving out bonuses for ranks, you’d probably have a leaderboard somewhere anyway. [/quote]
Even then, it would use less data too have a function too get the rank, instead of caching it.

[quote] I see a use-case where if you’re better than rank 10000 you get a bonus. And 1000, and 100, like in the summer clan battles.

“But really you should be caching data so that it would be a simple table lookup.” <- may as well do that, though. If you’re giving out bonuses for ranks, you’d probably have a leaderboard somewhere anyway. [/quote]
Even then, it would use less data too have a function too get the rank, instead of caching it.[/quote]

You’re better caching the data because if the DataStore request errors for any reason, your users will start seeing missing bits of data.

[quote]
You’re better caching the data because if the DataStore request errors for any reason, your users will start seeing missing bits of data. [/quote]
That can be true, So how would the caching work? Store it in a non-ordered datastore as well as an ordered? The way I would cache personally is using HTTPService, and storing on my own website. Unless I am thinking of it differently, unless you mean get the value only once store it in an int value, then update the datastore when user is done.

No. Get parts of the database when they don’t exist, and store them in a table for later use. When they’re updated in your game, update the cache and the real value. That way, if your datastore calls error, you still have the real value cached to be used later.

So I don’t understand what you guys mean to attain by “caching” the data. How would that allow me to do a “simple table lookup”? I mean, even if you save the player’s score in a table, how would you get the rank without either A) sorting it yourself or B) saving it in an OrderedDataStore and iterating through every value with the page object until you get to a matching value?

Edit:

I think a method like this would be quite nice, and @stravant: I don’t quite have statistical data to back it up, but I would think that if a game has both interesting and competitive gameplay, being able to see that you’re a low rank would be the opposite of discouraging - it would give the player a reason to keep playing and getting better at the game, to utlimately get a better rank.

2 Likes

[quote] As nice as showing a position sounds, it’s not actually very useful or nice for the user. Sure, if you’re one of the top 100 or whatever users on the game, then you like it… but for the 99% of users playing your game, knowing that they’re in 14,679th place in the rankings isn’t very helpful or fun.

It’s kind of a missing feature, but there isn’t really any use for it other than exactly this, and I don’t think that this is that helpful to begin with, so I don’t know if it’s needed. [/quote]

A game I play displays individual rankings like this. You usually start out in the millions, but it goes down very fast as you play and win. I found it quite satisfying whenever I dropped down another 100K, down to 10K, then eventually below 1000. It has served very well as a goal that has kept me playing.

Most uses of ordered storage that I’ve seen on Roblox are just stats that increase inherently as you play (kills, time played). These stats aren’t actually very interesting, and are almost impossible to gain any significant rank on unless you’ve been playing from the game’s inception, and continue to play indefinitely. Being able to show an individual’s position might encourage the creation of rankings that are actually competitive. Currently, it doesn’t really work because players cannot easily compare their rank with opponents, and they cannot see how they are improving. This only works for the top N players (N being however far one is willing to page through the ranks), which is catering to a very small group.

6 Likes

I am going to revive this topic, as I feel it will be necessary for my game leader-board coming up.

4 Likes

I could still use this as well, but it isn’t crazy important.

I would like to see this be implemented.

It is still currently impossible to do a hiscores like this with the current ordered data store. This feature is present in hundreds of other games and apps; encouraging competition between friends, or periodically checking your ranks as they climb, setting milestones to get within 100k, 10k, 1k, and top 10 etc.

I’d love to have the ability to do this in my game with datastores. OrderedDataStore:GetPosition(key) or the OP’s suggestion would be awesome!

image

(from bee swarm simulator:)

Corecii explains the current limitation here: OrderedDataStore get ranking? - #5 by Corecii

9 Likes

I want to show players their rank, not just their score.

OrderedDataStore:GetOrderIndex(bool isAscending, string key)

As a Roblox developer, it is currently impossible to get the order depth that a key is sorted in an OrderedDataStore.

If Roblox is able to address this issue, it would improve my game by showing players what rank they are on a leaderboard.

Example: Players play a game and earn points. Each player’s score is saved in an OrderedDataStore. The game can currently display the top ranked players on a leaderboard by using GetSortedAsync(). I also want to display to any user their rank so that they can watch as they progress or see where they stand.

12 Likes

@VitalWinter I do like this implementation adding the ascending bool, good addition for sure.

2 Likes

This feature would still be mega useful.

2 Likes

This is still missing in the API, and we’d find it incredibly useful in SCP: Roleplay. One of our roadmap goals is to implement a detailed list of stats per player, so that they can get information such as their total quests completed and how far off they are from the top of the leaderboard. Another scenario where we might need this is if we implement monthly events, with position-based rewards. A lot of popular outside-roblox games have this, and it’s kind of a bummer that Roblox does not have it (it’s impossible as it is right now for any popular game).

I’d really be looking forwards for something like this. Having to rely on an external database for data saving is not exactly ideal and having this implemented in Roblox itself would be the best way to go.

13 Likes