I don’t want to make the entire system, I want to do stuff like writing something and that will be saved in the server, and you can read it. I tried with datastores, but the requests might be alot in my game, which will make the requests be throttled. How do I achieve this? Thanks for reading
You could message the person who’s responsible for developing this first and see if they’re willing to impart that knowledge or some guidance regarding accomplishing this.
Honestly if the game is single player, then I doubt you’ll hit the request throttle. I’m assuming you want it so the posts can save and be loaded throughout different servers right?
I made something a little similar for a game called “Trade Central”: Trade Central - Roblox
Sadly due to the lack of requests per minute roblox gives, you’ll need to ration how many posts they can create per minute. The datastore limit is: 60 + numPlayers × 10
That means a single user if you want can create 1 thread every minute, and possibly 9 replies per minute. The only issue I’ve gotten though when doing this was when the datastores try to update too fast and the queue overflows. At that point what I decided to do was to use httpservice so that I could handle the incoming posts on my own without the terribly slow update queue.
With messaging service being a thing, I bet you could come up with a method that sort of creates a table of current threads in each server, and then saves the table to a datastore later on. It would be a wonky implementation that would prob take a little while to understand and get to be efficient, but I do believe it could be an alternative.
That’s where the bindtoclose event comes in. When a server gets shutdown or a server ends, you can use the bindtoclose event to check for that. Doing so also allows you to keep the server open for a slightly longer amount of time which can prevent data corruption upon users.
Inside the bindtoclose event function all you need to do is save the current table of forum posts to a datastore. It may not be the most efficient way, but it beats having to make an entire database for a website
I honestly don’t see a very efficient way of going about doing what you want considering roblox has a pretty terrible system for cross server communication atm. Their roadmap had some interesting stuff such as universal scripts and temporary data stores. If you want to wait for those upcoming additions then do so. Otherwise I’d recommend using http service
It uses a custom distributed key module I wrote so that it can store more than the 260000 limit, but for example’s sake, assume it’s one key.
I store the posts as so:
local Posts = {
[PostID] = {
Info = {
Title = "String";
Description = "String";
AuthorID = 1;
Date = os.time();
-- Various more info
};
Content = "String of **Markdown** text.";
};
[PostID] = {
Info = {
Title = "String";
Description = "String";
AuthorID = 1;
Date = os.time();
-- Various more info
};
Content = "String of **Markdown** text.";
};
};
local function Save()
-- Save Posts using my DataStore module
-- Use messaging service to notify servers that there's a new post
end
When a player joins, they fire a RemoteFunction called GetPosts, and the server returns the cached posts table.
Not terribly complicated. The hard part is the caching and key distribution.
A better way of doing it is having the server get it once and storing it all within a table. That way when a new player joins, it’s not preforming a data store request call. Anyways I can try to come up with a basic system that can get what you need done