1. Post #1
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    [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.
    Thanks
    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.
    Changelog
    Code:
    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
    [/release]
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Lua King x 19Useful x 10Funny x 2Dumb x 1Agree x 1Informative x 1 (list)

  2. Post #2
    Gold Member
    cameleot's Avatar
    July 2006
    3,090 Posts
    Finally.
    Reply With Quote Edit / Delete Reply Finland Show Events Agree Agree x 2Lua King Lua King x 1Dumb Dumb x 1 (list)

  3. Post #3
    King of the Oil Refinery
    Tobba's Avatar
    December 2008
    6,221 Posts
    Awsome, the second i needed this you released it
    Reply With Quote Edit / Delete Reply Sweden Show Events Bad Spelling Bad Spelling x 1 (list)

  4. Post #4
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    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.

  5. Post #5
    _axe_'s Avatar
    May 2007
    376 Posts
    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.
    Reply With Quote Edit / Delete Reply Netherlands Show Events Dumb Dumb x 15Funny Funny x 3Agree Agree x 1 (list)

  6. Post #6
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Awsome, the second i needed this you released it
    :buddy:
    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.
    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.
    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.
    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.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Friendly Friendly x 1 (list)

  7. Post #7
    Gold Member
    BomBom's Avatar
    April 2005
    262 Posts
    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 :)

  8. Post #8
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    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.
    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.

    Edit:
    "The server at lexi.org.uk is taking too long to respond."

    That's firefox.

    Tried Google Chrome

    "This webpage is not available.

    The webpage at http://lexi.org.uk/modules/sourcebans_example.lua 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?

    Edit2:
    Working, nevermind.

  9. Post #9
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,265 Posts
    :iia:

    Thank you for this!
    Reply With Quote Edit / Delete Reply Germany Show Events Agree Agree x 1 (list)

  10. Post #10
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    What do you mean by a bit laggy?
    Do you mean having sourcemod with metamod source and sourcebans makes your server laggy?
    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.

    Also i was going to make something like this for our admin mod cause we use sourcebans but this just made my day, thanks :)
    You're welcome. (:

  11. Post #11
    gamer_lv's Avatar
    November 2007
    121 Posts
    This is awesome. I was looking for something like this for a while now. Thank you so much.

  12. Post #12
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    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.
    Reply With Quote Edit / Delete Reply Australia Show Events Agree Agree x 2 (list)

  13. Post #13
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    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.

  14. Post #14
    [NNJG]Ben's Avatar
    January 2010
    68 Posts
    Yes,
    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.

  15. Post #15
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    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.
    Anyway, I've added new words and that.
    From server console:
    Code:
    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:
    Code:
    ] 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.
    Thanks.

  16. Post #16
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    Code:
    ] 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.

    Code:
    ] 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.

    http://onlinecomphelp.com/bans/

  17. Post #17
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    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:

  18. Post #18
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    I am currently a root admin.

  19. Post #19
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    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.

  20. Post #20
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    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.

    EDIT

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

    Edit2

    Web interface isn't updating.

  21. Post #21
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Okay, it is a problem with the Z flag. I removed the Z flag, and it worked perfectly..
    Ok, I'll get that fixed.

    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.
    Yep. I didn't think people'd ban for less.
    I'll look into lowering or not actually doing the ban if it's for shorter.

    Anyway, it works. I'm happy. I'll post any other bugs I find :)
    Good. :3:
    Web interface isn't updating.
    I don't think that's my fault, more info?

  22. Post #22
    [NNJG]Ben's Avatar
    January 2010
    68 Posts
    Ok, I'll get that fixed.


    Yep. I didn't think people'd ban for less.
    I'll look into lowering or not actually doing the ban if it's for shorter.


    Good. :3:

    I don't think that's my fault, more info?
    What would be the reason of the web interface not loading?
    I think it would most likely be the game server having trouble connecting to the web server.
    The Webpage is connecting fine, If we ban someone from the webpage, they are banned from the server also, but why wouldn't it update?

  23. Post #23
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Try putting lua_log_sv 1 in your server.cfg and checking for Lua errors in garrysmod/lua_errors_server.txt after banning someone.
    Are they banned for the full amount of time, even though the ban doesn't show up?

  24. Post #24
    [NNJG]Ben's Avatar
    January 2010
    68 Posts
    Yes,
    but they are banned on Sourcemod not Sourcebans.

  25. Post #25
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    I did say using SourceMod and this at the same time was probably a bad idea.

  26. Post #26
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    Every single command in SourceBans.lua has been removed from Sourcemod before adding SourceBans.lua. The player is completely banned for the full amount of time if they are banned using the web interface or in-game, but if you ban in-game it does not list the ban on the website. That's the only problem, which I'm not sure how can be fixed. Could it just be a problem with my host (xenon servers), in some way?

  27. Post #27
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Humor me and try temporarily disabling SourceMod with the quick and reversible fix I put in the main post, then try banning someone. As my server's incredibly active ban page shows, it works fine from the Lua, and my last local test with the concommands worked fine, so it's got to be something on your end.

  28. Post #28
    I'm Solo.
    Chief Tiger's Avatar
    April 2010
    467 Posts
    I installed this and I'm getting this:

    20:25:40 L 08/08/2010 - 20:25:23: [08/08/10 20:25:23][SourceBans.lua] Loading Admin Groups . . .
    20:25:40 L 08/08/2010 - 20:25:23: Lua Error: lua\includes\modules\sourcebans.lua:291: attempt to index global 'activequeries' (a nil value)

    Edited:

    That last thing happened only if the db initializes mid-game I think, but this happened after a fresh restart (and only on my authing):

    21:30:07 L 08/08/2010 - 21:29:49: "Stealth Merc<15><STEAM_0:1:11466439><>" connected, address "69.255.145.134:43620"
    21:30:07 L 08/08/2010 - 21:29:50: "Stealth Merc<15><STEAM_0:1:11466439><>" STEAM USERID validated
    21:30:11 L 08/08/2010 - 21:29:53: Lua Error: Hook 'SourceBans.lua - PlayerAuthed' Failed: lua\includes\modules\sourcebans.lua:118: invalid value (nil) at index 6 in table for 'concat'
    21:30:11 L 08/08/2010 - 21:29:54: "'{CS} Chief Tiger<4><STEAM_0:1:22240086><>" entered the game
    21:30:12 L 08/08/2010 - 21:29:55: "{/MBG\} Mitch710<9><STEAM_0:1:26505460><>" entered the game

    Edited:

    This happened shortly after banning myself for 1 minute:

    21:34:39 L 08/08/2010 - 21:34:21: Lua Error: [08/08/10 21:34:21][SourceBans.lua] The server has lost connection to the database. Retrying...
    21:34:39 L 08/08/2010 - 21:34:21: Lua Error: Timer Error: lua\includes\modules\sourcebans.lua:560: attempt to index local 'query' (a nil value)

  29. Post #29
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    That seems to be why the web server isn't updating... Right?

  30. Post #30
    I'm Solo.
    Chief Tiger's Avatar
    April 2010
    467 Posts
    Yes. My webserver isn't updating with my bans.

    Edited:

    I have Sourcemod disabled too, but I'm using this module with Evolve.

  31. Post #31
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    I've uploaded a version that should prevent all three of those errors.
    However, the middle one is because you have access to the server, but haven't been assigned a server group. You might want to fix that?

  32. Post #32
    I'm Solo.
    Chief Tiger's Avatar
    April 2010
    467 Posts
    I'm confused by that statement, do you mean on the server or on the the website? I have dogroups set to false in the lua...

  33. Post #33
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Go to the admin list.
    Then look at your name.
    Then look at the column next to it, the 'Server Admin Group' one.
    If it says 'No Group/Individual Permissions', then that's the problem.
    If it doesn't I might need access to your installation to see why you're assigned a group without a name.

  34. Post #34
    I'm Solo.
    Chief Tiger's Avatar
    April 2010
    467 Posts
    Ok, but will those groups have to match the ones on my server?

  35. Post #35
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    If you want to be able to manage who gets put into what group via the web interface when Overv gets around to making it work properly, (or if you use the plain version and only have Admin and SuperAdmin) then yes.
    Otherwise, don't bother. You don't even actually need to bother doing the groups in that case, as I tostringed it. I'll just announce in the server log that you're a 'nil'. I'll get around to neat-ifying that later.

  36. Post #36
    I'm Solo.
    Chief Tiger's Avatar
    April 2010
    467 Posts
    Ok, but is there any reason why when I ban someone, that the ban doesn't appear on the website and I can't unban the person through evolve or sm_unban?

  37. Post #37
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Are you using the latest version of the module? Any errors? I've not run across this before.

    Edited:

    Actually, if the database is not active when you ban someone through Lua, it returns an error to the callback function rather than printing an error. Overv may not be handing them.

  38. Post #38
    I'm Solo.
    Chief Tiger's Avatar
    April 2010
    467 Posts
    Btw, you have a typo on line 175. :3:

    Edited:

    It seems that there's something wrong with my database connection, because when my admins use the ban command it gives this error:

    Plugin 'Ban' failed with error:
    lua\includes\modules\sourcebans.lua:504: attempt to call local 'callback' (a nil value)

    Which is fine if Overv hasn't made callbacks yet, but that only gets called if checkConnection() returns false.

  39. Post #39
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Fixed typo, added a bit more robustness and bugged Overv until he said he'd do callback support.
    v1.315 now online.

  40. Post #40
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    The website is up, only, and working, but...

    Code:
    ] sm_ban gash 1 being innocent.
    The database is not active at the moment. Your command could not be completed.