I have a working ban system, however I’d like to store the bans somewhere, but since I can’t store anything but numbers with ordered datastores, it seems like I need to use an external website (because I store reason and such in the datastore).
Couldn’t you just create a table with all of the bans as a sort of database? If your DS gets to the limit (4mil characters), you can create a second datastore to act as a secondary database.
Well, yes, but then I need to create another datastore to rely on, just to update their information to that.
Could work though, I was thinking that as well before making this post.
If you’re still considering it, I’m thinking you could just store the player’s ban inside of their normal data, then inside of the “database” you could just have a table with a list of cases. The index could either be a number or their user ID.
For example,
local cases = {
[123456] = {
['TimeIssued'] = 123456789; -- I'd use os.time() to do this
['Reason'] = 'did a bad thing';
['Moderator'] = 'cool mod name'
}
}
Then if you’re missing a case from the case list, you could do something like this to get the info from the player’s data
local dataStoreService = game:GetService('DataStoreService')
local caseList = dataStoreService:GetDataStore('CaseListDataStore')
local playerData = dataStoreService:GetDataStore('PlayerData')
local cases = caseList:GetAsync('CasesDatabase1')
-- then later if you want to get a certain player's ban info, live or if a case is missing then
local userId = 123456
local playerInfo = playerData:GetAsync(userId) -- get the player's data
local banInfo = playerInfo.BanInfo
if banInfo.Banned then
print('Live ban info: ',banInfo)
if not cases[userId] then
cases[userId] = banInfo
end
caseList:SetAsync('CasesDatabase1', cases)
end
I can do that, yes, but the thing is I cannot store anything else but numbers in a ordered datastore.
That will be problematic as I store more than numbers.
Yeah, I’m thinking you could take the key returned from the pages object to get their actual ban data, the 1 is just more of an indicator than anything.
They do only use strings but it gets converted when calling :GetAsync AFAIK. tostring is probably called inside of the function. It happens a lot in other functions too. If you do Vector3.new(‘123’,‘123’,‘123’), it will return a Vector3 as normal.
I’m sure you could use looping or some other method to check if a datastore is full.
And if you’re retrieving data, just use a module that does the same; looping through all datastores and checking for player data.
It should also be said that if multiple copies of data (or second data indexes) appear then it should remove all but the oldest existing save.