How should I save/get bans?

I wanna make a ban command, but the problem is that I don’t want data store requests to be spammed when someone enters a game just to see that they aren’t banned. An idea that I had was to use a global table to store bans and then, using game:BindToClose(), I save the data when the server shuts down. The honestly seems like it is a better option in my eyes, but I want to see the community’s opinion

1 Like

How exactly would the ban DataStore get spammed? I don’t understand.

1 Like

Personally I’d recommend TheDevKing’s YouTube video on this topic. You can follow it step by step and he explains it really good along the way. Make sure you are using your resources such as Google, YouTube, and other DevForum posts before making your own!

2 Likes

Best way is you store the banned people in a list and only request on server update and every 10 minutes if a player joins.

Not what OP is asking. They’re looking to ban people in a different way than is standard. Please read the entire OP carefully before replying.

1 Like

@zachariapopcorn You first get the table on server start from datastore. When you ban new players you save the ban on datastore and then use MessagingService to update the existing servers and only send the newly banned player trough messaging service.

2 Likes

Say if you have a a lot players joining your game, and every time someone joins your game, the game would do GetAsync() to get data to see if the player is banned, but what happens if the game manages to go over the limit? It won’t kick banned users. That’s what I kinda worried about

1 Like

You could hold the player(s) in a queue until it returns a value (if success and data then).

The most common way I think this is done is the following:

  1. On Server Start, get banned list from datastore.
  2. Every time players join, reference that stored table. Kick if they are on it.
  3. Fetch the table from datastore every minute or so, overwriting your old table.
  4. If adding new players to list, force a save to datastore so other servers get updated list.
  5. in the event that a banned user goes to a new server too quickly to bypass the delay between list fetches, have all servers re-check every player in the game every few minutes or so.
1 Like