Module sourcebans

Sourcebans.lua provides an interface to SourceBans through GLua, so that SourceMod is not required. It also attempts to duplicate the effects that would be had by running SourceBans, such as the concommands and convars it creates.

Note that if the concommands are not wanted (for integration with an admin system that has it's own commands, for instance), the global value SBANS_NO_COMMANDS should be set to true before the require("sourcebans") call.

This module requires that gmsv_mysqloo.dll is installed on the server, and will use gmsv_gatekeeper if it is installed.

Release: version 1.531, now GM13 compatible!

Functions

Activate () Starts the database and activates the module's functionality.
BanPlayer (ply, time, reason, admin, callback) Bans a player by object
BanPlayerByIP (ip, time, reason, admin, name, callback) Bans a player by IPAddress
BanPlayerBySteamID (steamID, time, reason, admin, name, callback) Bans a player by steamID
BanPlayerBySteamIDAndIP (steamID, ip, time, reason, admin, name, callback) Bans a player by SteamID and IPAddress
CheckForBan (steamID, callback) Checks to see if a SteamID is banned from the system
CheckStatus () Checks the status of the database and recovers if there are errors WARNING: This function is blocking.
GetAdmins () Gets all the admins active on this server
GetAllActiveBans (callback) Fetches all currently active bans in a table.
SetConfig (key, value) Set the config variables.
UnbanPlayerByIPAddress (ip, reason, admin) Unbans a player by IPAddress.
UnbanPlayerBySteamID (steamID, reason, admin) Unbans a player by SteamID


Functions

Activate ()
Starts the database and activates the module's functionality.
BanPlayer (ply, time, reason, admin, callback)
Bans a player by object

Parameters

  • ply: The player to ban
  • time: How long to ban the player for (in seconds)
  • reason: Why the player is being banned
  • admin: (Optional) The admin who did the ban. Leave nil for CONSOLE.
  • callback: (Optional) A function to call with the results of the ban. Passed true if it worked, false and a message if it didn't.
BanPlayerByIP (ip, time, reason, admin, name, callback)
Bans a player by IPAddress

Parameters

  • ip: The IPAddress to ban
  • time: How long to ban the player for (in seconds)
  • reason: Why the player is being banned
  • admin: (Optional) The admin who did the ban. Leave nil for CONSOLE.
  • name: (Optional) The name to give the ban if no active player matches the IP.
  • callback: (Optional) A function to call with the results of the ban. Passed true if it worked, false and a message if it didn't.
BanPlayerBySteamID (steamID, time, reason, admin, name, callback)
Bans a player by steamID

Parameters

  • steamID: The SteamID to ban
  • time: How long to ban the player for (in seconds)
  • reason: Why the player is being banned
  • admin: (Optional) The admin who did the ban. Leave nil for CONSOLE.
  • name: (Optional) The name to give the ban if no active player matches the SteamID.
  • callback: (Optional) A function to call with the results of the ban. Passed true if it worked, false and a message if it didn't.
BanPlayerBySteamIDAndIP (steamID, ip, time, reason, admin, name, callback)
Bans a player by SteamID and IPAddress

Parameters

  • steamID: The SteamID to ban
  • ip: The IPAddress to ban
  • time: How long to ban the player for (in seconds)
  • reason: Why the player is being banned
  • admin: (Optional) The admin who did the ban. Leave nil for CONSOLE.
  • name: (Optional) The name to give the ban
  • callback: (Optional) A function to call with the results of the ban. Passed true if it worked, false and a message if it didn't.
CheckForBan (steamID, callback)
Checks to see if a SteamID is banned from the system

Parameters

  • steamID: The SteamID to check
  • callback: The callback function to tell the results to
CheckStatus ()
Checks the status of the database and recovers if there are errors WARNING: This function is blocking. It is auto-called every 5 minutes.
GetAdmins ()
Gets all the admins active on this server
GetAllActiveBans (callback)
Fetches all currently active bans in a table. If the ban was inacted by the server, the AdminID will be "STEAM_ID_SERVER".
If the server does not know who the admin who commited the ban is, the AdminID will be "STEAM_ID_UNKNOWN".
Example table structure:
{ 
  BanStart = 1271453312,
  BanEnd = 1271453312,
  BanLength = 0,
  BanReason = "'Previously banned for repeately crashing the server'",
  IPAddress = "99.101.125.168",
  SteamID = "STEAM_0:0:20924001",
  Name = "MINOTAUR",
  AdminName = "Lexi",
  AdminID = "STEAM_0:1:16678762"
}

Bear in mind that SteamID or IPAddress may be a blank string.

Parameters

  • callback: The function to be given the table
SetConfig (key, value)
Set the config variables. Most will not take effect until the next database connection.
NOTE: These settings do *NOT* persist. You will need to set them all each time.

Parameters

  • key: The settings key to set
  • value: The value to set the key to.

Usage:

Acceptable keys: hostname, username, password, database, dbprefix, portnumb, serverid, website showbanreason and dogroups.
UnbanPlayerByIPAddress (ip, reason, admin)
Unbans a player by IPAddress. If multiple players match the IP, they will all be unbanned.

Parameters

  • ip: The IPAddress to unban
  • reason: The reason they are being unbanned.
  • admin: (Optional) The admin who did the unban. Leave nil for CONSOLE.
UnbanPlayerBySteamID (steamID, reason, admin)
Unbans a player by SteamID

Parameters

  • steamID: The SteamID to unban
  • reason: The reason they are being unbanned.
  • admin: (Optional) The admin who did the unban. Leave nil for CONSOLE.

Valid XHTML 1.0!