I am planning to implement a system in my game where players can easily fetch a random gamepass ID and server ID at a specified price. The pool of available gamepasses will be automatically updated every time a player joins the game; it will fetch the player’s gamepasses and add them to the list (datastore) of available gamepasses that can be randomly selected based on the given price.
(the “list” contains every gamepass from each player from every server; its a cross-server market).
The main gimmick is that players can be prompted to buy a random gamepass from the “pool” of gamepasses (the ones added into the datastore) with the same price (given by the player). Its relatively important that this system allows for efficient selection and removal of gamepasses for when the player joins/leaves.
This means that A: The system/way of saving data should allow for easy random gamepass selection based off of price. B: Be able to efficiently remove the players owned gamepasses WHEN the player leaves.
Do you guys have any solutions/suggestions for creating such system? I want to hear your thoughts about it
like especially how i should organize the datastore(s), and how i should generally approach with creating the system itself
EXAMPLE to help demonstrate what i mean
the player joins the game, and their gamepasses and server ID are added to the datastore.
the player requests to receive a random gamepass prompt from the datastore with a specified price of 5 Robux.
only gamepasses priced at 5 Robux are considered for the prompt.
the player is prompted to buy a random gamepass from the datastore that matches the specified price.
player buys the gamepass
when the player leaves, their gamepasses are removed from the datastore to prevent others from buying gamepasses from players who are not in the game.
It sounds like a memory store would be much better suited to this use than a data store - they are designed to be updated frequently, whereas data stores are not.
You can add it to the memory store so that new servers can retrieve all the gamepasses data, but I would recommend messaging service to tell the servers when to update.
Storing it all under one key will be hard to do and will likely exceed the key limit if your game gets a lot of players. It also brings the issue of rate limiting, should you use ListItemsAsync, but it can be done.
Only store the gamepass ID, and use marketplaceservice’s GetProductInfo if you want to display any info about the pass.
hey!! apologies for the late reply, and thanks for the feedback!
before posting, I did consider using MemoryStore for this system but forgot to mention that I’m also open to suggestions on how to integrate MemoryStores (or generally anything) effectively in the case Datastores weren’t optimal.
I didn’t originally plan to store everything under a single key; I just wanted to hear some opinions on how the system could be structured.
also, regarding storing only the gamepass ID, I thought it might be useful to also store the price for this type of system. while you can use GetProductInfo to retrieve gamepass details, constantly calling it for every stored gamepass ID would quickly hit API throttling limits.
MemoryStores definitely seem like a good fit for this type of system. However, I’ve heard they have a time limit, after which keys are dropped, and are more suited to short tasks. that’s not a huge issue (i assume) since you can always set the key again once it’s dropped.
that being said, I’m curious if there are any MemoryStore methods that could make it easier to query values. For example, if I wanted to fetch all gamepasses priced at 5 Robux, would that be possible without hitting too many limits or risking dropped requests? Is there a built-in method in MemoryStore to query all gamepasses by price, like in this case?
If you’re referring to the expiry of the data, it really won’t be an issue. The default expiry is 45 days.
As for memory store methods, I’m pretty sure that ListItemsAsync is your best option here, I don’t think there’s a built-in method for filtering.
This could be a stretch but the web API for memory stores might have a filter, the same way listing banned users via http requests has &filter=game_join_restriction.active=='true'. If not, you’re just going to have to iterate over all those pages.
If I’ve missed anything, please let me know, otherwise I’m going to sleep now so might take a while to reply.