Best way to store data (?)

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).

What website should I rely on when storing bans?


Feedback is appreciated.

3 Likes

I think you can use trello api I’m not familiar with it but a lot of ppl use it for those types of things hope this helps.

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.

1 Like

Gotcha.

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
1 Like

I already implemented this, I was only thinking about a live banlist, similar to what :GetOrderedDataStore() offers.

1 Like

Hmm.

I’m thinking you could set a value to 1 if the user is banned, and :GetSortedAsync does give us an option for minimum values.

datastore:GetSortedAsync(true, 50, 1 --[[here's where the min value would go. if 1 indicates a ban, then it would only return banned users]])

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.

1 Like

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.

I still need another datastore though.

1 Like

Oh yeah, that’s true. Not really sure where to go from here, sorry.

datastore getasync dont use numbers, sir

Wdym? The user id would be the the key.

i mean, make the userid to a string [ “69420” ]

It shouldn’t matter. I use the raw user id integer and haven’t run into any issues.

i believe datastores only use strings, if im wrong then it means my datastore wrapper is the problem

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.

No, they do not.
The only thing you cannot store with DataStore is instances, everything else is perfectly fine.

i mean the names