BanManager | A light-weight ban handler!

Update

  • Added a new extra data parameter in the .Ban function, can be retrieved using .GetBanData
  • Added a new .GetBanData function, replaces the old :IsBanned function. Returns the ban data of a specified UserId
  • More info in documentation

(Credits to @0bBinary for the idea)

3 Likes

nice updates!!!
I hope you get more recognition for this.

1 Like

If this uses DataStoreService, I suggest you change it to ProfileService.

If this is used in a popular game (ex. 200+ concurrent players) and uses Robloxā€™s default DSS, ban data for some users could get reset and theyā€™d be unbanned.

Iā€™m sorry but just regular DataStoreService hasnā€™t let me down yet, even for some games Iā€™ve worked on that had 10k+ concurrent users. Thanks for the suggestion though, but I donā€™t have the time to implement it right now.

2 Likes

ProfileService still uses normal datastores. the point of that module was for session locking. there will not be data loss with the average datastore esprcially with banning.

2 Likes

how can you make it a permanent ban?

1 Like

Set the BanLength to nil.

BanManager.Ban(1, "You are banned", nil, {ExtraData = 100})

Another way:

BanManager.Ban(1, "You are banned")

will this work with players not in-game?

Yes.

Maybe add a setting within the module to allow the module to kick any users if their data fails to load? If theyā€™re banned and their data doesnā€™t load, then theyā€™ll be allowed to join the game. Itā€™s not too likely to happen, but sometimes outages occur.

Update

  • Added ProfileService to the module, if there are any bugs, please inform me quickly so I can fix them
  • If you already have ProfileService in your game, make sure to delete the one under BanManager and reference the already existing ProfileService in the BanManagerā€™s main script
  • Iā€™ll also start adding the version number in the BanManagerā€™s name so itā€™s easier to differentiate the versions when I can

(@benpinpop The module should now kick players if their data does not load correctly in order to prevent people who have been banned joining when they shouldnā€™t)

1 Like

This is a really interesting module but you should add two things:

  • the agility to have a custom kick handler, this could be implemented using BanManager:SetKickHandler(handler: (player, banData)->()), which would be really useful to add additional informations to the kick message or even teleport player to a game instead of kicking him
  • the ability to use custom datastore service with BanManager:SetDataHandler(getUserData:(userid: number)->any, setUserData: (userid: number, data: any)->(success: boolean)) it would be useful for develeopers who use their own systems or even external database

This is just for basic uses for newer people who donā€™t know/have the time to make a ban system.

Adding a custom data handler for people to use would overcomplicate things for the average user and if you are going to do that, you might as well make it yourself since you have the know how of making a ban system.

I might add that one day but if you want that functionality right now, you can go ahead and edit the source codeā€™s Ban function.

Sorry but I reverted the update due to some bugs, I will update it when everythingā€™s polished.

1 Like

Update

  • Added .GetBanDatas to return a record of banned players, look at the documentation for more information (Suggested by @vxsqi)
  • Kicks player if loading fails, to prevent banned players from joining

Sidenote: Iā€™m looking into adding custom ban messages based on functions

2 Likes

That GetBansData was a needed addition. Iā€™ve been using this resource for a long time, and i had to make up my own hacky solution with datastore to achieve that.

Also what are the limits for this? How many bans would it take to break a datastore limit?

Also are you sure the kick method is the best way of solving the failing to load issue?

1 Like

.GetBanDatas by default returns every key available. Thereā€™s a limit parameter you can add which I would personally use.

Roblox datastores can store (virtually) infinite keys Iā€™m fairly sure, so you donā€™t have to worry about not having enough storage to ban millions of people.

The only thing that Roblox does limit though is the value in each key, so as long as you donā€™t cram a ton of data in ExtraData, you will be good.

I would say it is, as for me itā€™s better to kick out an innocent player than let an exploiter in your game wreck havoc.

If you have any suggestions for that though, Iā€™m open to hearing it.

Edit: Now that Iā€™m thinking about it, I could try teleporting them back to the game if it fails, would that be a good idea?

Thank you very much! Your CanvasDraw module was also very helpful for some of my projects, and to be honest, I was happily surprised when you commented.

2 Likes

Minor update

  • Removed the useCache option
  • Fixed type inferences

Sidenote: I removed this because I feel like this is useless bloat since you can create a cache yourself in a more efficient and succinct manner

It seems to be kicking me as soon as I require the module. I think itā€™s because LoadBanData() is returning nil even though it passed through the if success statement?? Am I doing something wrong?

I made a fatal error in the module, my apologies. It has been fixed.

1 Like