SourceBans in Lua

[release](Shiny banner goes here)
SourceBans In Lua version 1.531 (Last Update: 25th December 2012)
I’ve been working for a while on getting an implementation of SourceBans going in GLua, so that the benefit of a nice global banning system can be had without the large downside of having to install MetaMod:Source and SourceMod.
The result is Sourcebans.lua!
This is two things in one:
Firstly, it is a complete replacement that a server owner can put in instead of the SourceMod version, and it will continue as normal.
Secondly, it is a tool developers can use to create in-game admin mods that completely integrate with SourceBans, allowing you to view bans in-game and use useful menus instead of the concommands.
For instance, Overv has done this with Evolve, which is now SourceBans compatible.
For Server Owners

  • Uninstall or disable Metamod by moving metamod.vdf from garrysmod/addons/ to garrysmod/addons/metamod/.
  • Install MySQLOO. Get it [Here].
    Place libmySQL.dll orangebox/ and gmsv_mysqloo.dll in orangebox/garrysmod/lua/includes/modules/
  • Install SourceBans.lua. Get it [Here].
    Download the file and place it in garrysmod/lua/includes/modules/ next to gmsv_mysqlloo.dll.
  • Install the setup file. Get it [Here].
    Download the file and place it in garrysmod/lua/autorun/server/ and then fill out all the details with your own.
  • Start your server.
    Everything should work as normal.
    For Developers
    I have used the handy LuaDoc system to provide full documentation for the module.
    You can find it [Here].
    Please report back if you use this or have any trouble.
    The people who made SourceBans in the first place.
    The people on my server for being unwilling test pilots
    Overv for lots of testing and being the first adopter.

1.531 Tiny change to make the source GM13 compatible (no more | operator!)
1.53  sm_rehash now goes through all online players and makes sure their group is up to date.
1.521 Fixed a hang if an admin had no srv_flags and no srv_group
1.52  Added various sm_#say commands at a request, and added a SBANS_NO_COMMANDS global variable to disable all admin commands (for pure lua usage)
1.51 Made it work again
1.5   Made it support gatekeeper
1.41 Fixed yet another 'stop loading admins' glitch
1.4 Added GetAdmins(), made it work a bit more.
1.317 Added even more error prevention when an admin doesn't have a server group but is assigned to the server
1.316 Added error prevention when an admin doesn't have a server group but is assigned to the server
1.315 Made sure callback was always actually a function even when not passed one, fixed a typo.
1.31 Added some error checks, removed some sloppy assumptions and fixed queued ban checks not working.
1.3 Pimped up the concommands and made them report more details
1.22 Added dogroups to the config to disable automatic usergroup setting
1.21 Made it so that the player is only kicked if their user object is available
1.2 Made CheckForBan() and BanPlayerBySteamIDAndIP() accessable
1.12 Made the concommands check that the right amount of arguments had been passed.
1.11 Fixed a typo that stopped the fix working
1.1 Fixed the module freezing the server by pinging the database 10 times a second



Awsome, the second i needed this you released it

So, this uses the normal web interface of Sourcebans?

Can I also run sourcemod with this? I disabled all sm_ban commands, so non of them will be used with sourcemod. All the sm commands in your Sourcebans.lua file are removed from the sourcemod I use.

Is this a replacement for the VAC security?
And does this use a global database wich has write and read permission from every server wich installed this.
Like, if someone gets bannes by this system somewhere for a normal reason, he gets banned on all servers
using this, and for breaking the private rules of the server, he only gets bannes on that particular server.

Here is a siggestion. Why not create certain server rules profiles.
Like, this server is for rp, and serious RP only.

Someone playing on this server breaks one of the rules in the serious RP profile.
This someone gets bannes from all servers using this serious RP profile.
Like, the ban gets tagged with this profile relation only.

But once he breaks some of the standard rules like cheating, this persons just gets banned
from every server using this.


Yes, and potentially. the sm_rehash command might cause problems, I don’t know.
Why do you want to run SourceMod in Garry’s Mod? It seems redundant to me.

No, this is a Lua version of [This] system, which allows you to have a ban enacted on every Source based server you own. It does work in Garry’s Mod, but it’s a bit laggy so I made a native version.

What do you mean by a bit laggy?
Do you mean having sourcemod with metamod source and sourcebans makes your server laggy?

Also i was going to make something like this for our admin mod cause we use sourcebans but this just made my day, thanks :slight_smile:

sm_rehash is also removed, all ban-related commands from sourcemod are removed.

And I use it for the Rtv/Nominate plugins. And some others on Allied Modders.

“The server at is taking too long to respond.”

That’s firefox.

Tried Google Chrome

"This webpage is not available.

The webpage at might be temporarily down or it may have moved permanently to a new web address."

Site down? Maybe you should post the code here on FP?

Working, nevermind.


Thank you for this!

It drops your server FPS a bit and according to Connameku or whatever his new name is, it seends a huge networking spike every 5 minutes.

You’re welcome. (:

This is awesome. I was looking for something like this for a while now. Thank you so much.

I made my own ages ago for ULX(been using it alongside my ULX MySQL admin list). And when I made it, I couldn’t understand why no one had done it yet.

Nice work.

Just added it, and I just tried something.
It doesn’t work in-game, it doesn’t even do anything when I type in “sm_ban”

No error message, or anything. I banned myself using the Web interface, and THAT worked. It just doesn’t seem to want to work in-game using sm_ban, sm_addban, or any of those.

I have the same problem.
Also, sm_ban doesn’t work unless you type writeid in RCON after it, but still doesn’t go to the website.

Ok, looked into it, uploaded a new version that should work better.
The main reason you weren’t receiving feedback is that I’d forgot to import HUD_PRINTCONSOLE. :v:
Anyway, I’ve added new words and that.
From server console:

sm_ban lexi 5 testing
sm_ban: Your ban request has been sent to the database.
Dropped Lexi from server (Kicked by Console :  You are BANNED from this server!)

sm_ban: Lexi has been banned successfully.

From my console:

] sm_addban 120 STEAM_0:1:17496864 Using 'omg! :D' in a serious roleplay event
sm_addban: Your ban request has been sent to the database.
sm_addban: STEAM_0:1:17496864 has been banned successfully.

Please download the latest version of the module from the post or [Here] and tell me how it works out for you.

] sm_addban 14440 STEAMID Rdming
You do not have access to this command!
clafair (STEAMID) connected from Canada
NutterButter: Im going to top floor
NutterButter: Im in the building
] sm_rcon sm_addban 14440 STEAMID Rdming

I’m admin on the users file, ulx admin, sourcemod admin. Even admin on the bans website. It didn’t update on the website either.

] sm_ban gash 1 test
You do not have access to this command!

I also banned myself using the web interface, and it didn’t even ban me this time. Just kicked me.

the sm_ commands require various access levels like the normal sourcemod.
You need to grant yourself ADMFLAG_BAN, ADMFLAG_RCON and ADMFLAG_UNBAN from the SourceBans website.
Like so:

I am currently a root admin.

It could be a problem with the z flag… Could you quickly try with z off but all the others on please? I’m not in a position to test right now.

Okay, it is a problem with the Z flag. I removed the Z flag, and it worked perfectly… BESIDES the fact that a one minute ban did not unban me after one minute, and sb_reload didn’t unban me either once the ban expired.

I had to manually sm_unban myself.


I tried it again, does it ban you for 5 minutes by default if it’s lower then 5? Because that’s what it did… lol, I banned myself for 1 minute, took 5 minutes. Banned for 5 minutes, took that long.

Anyway, it works. I’m happy. I’ll post any other bugs I find :slight_smile:


Web interface isn’t updating.