I would like to add logs to my game where all the commands performed across all servers by any admin are stored along with a reason for using that command, so basically if I got a report from a player that he was abused by an admin a week ago I could open up my logs and check out the command used by the admin and their reason. I would try using roblox data storage but I am unsure how effective that would be in the long run.
I belive from my research that http service is the way to go, but the API reference isnt enough for me to learn how to use http service (the see also link doesnt exist). If anyone could tell me a good way to do logs and give me some resources to learn how to use http service I would appreciate it.
I just checked the API reference and article on messaging service and although it would allow global logs I dont really know how I would be able to store data with it. Thanks for introducing me to something new tho
You could instead just save the data to a datastore and every so often request the data (from different servers), then when a client would like to view the command logs you broadcast the data to them.
For saving the data I suggest saving all commands that were entered every minute and then after that minute has passed you save them all, and clear the list and then repeat that. (To save SetAsync / UpdateAsync calls)
I believe using data storage be would be the most effective way to do this.
You could save all commands in a data store as a table containing other tables, each one being the name of the player that has access to commands, followed by all commands used. So for example:
Once the admin has used their first command and their name is placed in the table of commands, you could then just place all subsequent commands into their table using table.insert or whatever your preferred method is.
If you wanted to take things a step further you could keep track of on what date each command was used and then remove commands that are more than a week old or whatever, although this would likely be unnecessary.
Also, to avoid flooding the datastore with requests and therefore dropping data, you should save all commands a player uses in a server in some table of a script, and then ONLY actually insert the commands used either when the player leaves the game or when the server closes.
If done correctly you should have no issue with this method.
Yeah datastore sounds like a great solution but I just noticed there is a simple but quite annoying problem with datastores. Your data could quickly become unmaintainable and could soon become unable to even be saved because of the length of the serialized data.
You might want to create separate datastores for commands called every hour or day to prevent something like this from happening. You could also try employing a length check to make sure the data does not go over the specified limit.
I based the 438216 and 438217 off the current amount of hours passed since Epoch.
local hour = math.floor(tick() / 60^2)
More Over
If you wanted to you could also try compressing the data to allow a longer amount of data to be stored per entry. Perhaps you replace every command with a “keyword” (assuming the keyword is shorter than the actual command).
The “Kill” command could be command id “1” reducing a message such as :kill all to :1 all. You could also remove the command prefix because you could assume it is always the same. :1 all → 1 all.
And perhaps if you also have special keywords in your admin to call a command on everyone or a specific group of people you could add those. Let "a’ be a keyword for “all”, now you have 1 a.
You could even remove the whitespace. This turns 1 a into 1a, leaving you now with an extremely reduced version of the original data. (9 characters to 2)
So by editing the module [Game Analytics] you can implement a funtion
that (https://www.roblox.com/library/852697204/Game-Analytics) you can easily track ( whether or not / how many times / what ) they typed in a command. Just store your commands in a table and match them with what your admin typed with the player.Chatted function.
Ok, so thanks for the feedback, I will tell which solution I used after I do some testing to see wich one is best for my game, all solutions right now seem like they would work out. Anyways I still would like to learn about http service for other reasons but I cannot find any good resources to help me out here (keep in mind this would be my first time using http service), so if anyone could give me resources to learn how to use http service I would appreciate it.
The thing with HTTPService is that you can’t really “learn” it. Each website handles requests (which HTTPService makes) differently and you have to deal with each use case on a case-by-case basis. If you shoot me a DM, I can introduce you to the basics but after that you’ll have to just kinda learn while you go.
Here’s a video I found that goes a little bit more in depth (not Roblox related) about how the different requests that you can make via HTTPService.