How to implement a server-wide system?

How can I implement a server-wide market, where players can buy or sell resources to each other, and a server-wide auction, where players can bid for resources?

1 Like

Still haven’t figured out how, anyone know what service I should use?

Is there even a way? Or is messagingService the only possible solution?

This really sounds like something for DataStoreService which gets checked every once in a while, for immediate updates without having to strain the datastore you could use MessagingService on top of it. If you plan to moderate trades or duplications it would also be beneficial for everything to be given a unique id and every “transaction” giving it a trackable id too so you can easily figure out where an item is and everywhere it has been.

a mix of messaging service + profile service would probably do the trick.
-you need profile service for the session locking (from my understanding a pain todo yourself)
-messaging service to do communication after

In my game, which for context is a metallurgy game, players can smelt things they’ve bought into new alloys, how could I keep track of the resources sold if that happens?

hmm, what does messaging service allow to transfer btw, and how much?

My original idea was that messagingService can be used to send to every server a new auction or sale, and then when the user puts a bid or buys the resource, the message is sent back to the original server, where then it is proccessed to confirm the transaction, then it would send another message back to the bidder/buyer’s server, which is the confirmation, which then adds the item to the buyer

The limit for MessagingService as described here is 1kB (kilobyte) and with the amount per minute being 150 + (60 * players in server). As long as you have a good data stream you could compress this data enough to be able to fit within the ~1000B given (1 character = 1B for example with a string type).

When creating the “resource” for the first time it should be initiated with a unique identifier, this identifier should never change. To get a unique ID you could use something like HttpService’s GUID system, HttpService:GenerateGUID(). But also, doing this may be overkill depending on how crucial trading will be in your game, if trading doesn’t play a large role then I wouldn’t bother with all of this.

But multiple resources can and often are smolten together into a new resource, so what unique identifier should i do?

Also a resource is described as a dictionary, indexed by the element name and valued being a number representing the mass (in kg) of that element in the resource. So how could I compress this?

I believe you’d need to use Memory Stores to achieve this.

Alright, I will attempt that once I finnish a current system on implementing ratios.

Also should I rate-limit players selling, buying, and/or expecially with bidding? And also will it be possible to simulate a “Server” player, which acts as any other player, with a finite inventory. With this simulated player being able to automatically auction, buy or sell if prices are optimal? This would be good with the early era of my game release, were there would probably not be enough regular people to sustain a wide enough market.

In addition, is there a way to get the server at which the seller of the resource is, and then anyone who sees that item on the sale can join the seller’s server if it isn’t full?

I’ve never used memory stores myself so I can’t really help you or give you advice, but good luck on figuring this out.

1 Like

Begining with the script now, made 5 ways for the server and client to interact for the market, should be enough connections I think.

image


What should I set expiration and priority to?

Do I use queues or maps? With maps its easier to fetch the data for unique items on the market, and with queue its easier to find data, but is tedious to manipulate data.

Im currently trying to implement a system like this and not finding anything. Mind sharing how you did it?

session locking is not a pain. its metadata that stores an os.clock result, everytime u load a datastore just check to make sure its not locked and if it is make sure os.clock is > 30 mins or smthn (prevent dead locks)