SourceBans Documentation

SourceBans Documentation

SourceBans Download

All functions below must be called server-side!

sourcebans.Activate()

  • Starts the database and activates the module's functionality.
  • sourcebans.BanPlayer(ply, time, reason, admin, callback)

  • Bans a player by object
  • 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.
  • sourcebans.BanPlayerByIP(ip, time, reason, admin, name, callback)

  • Bans a player by IPAddress
  • 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
  • sourcebans.BanPlayerBySteamID(steamID, time, reason, admin, name, callback)

  • Bans a player by steamID
  • 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.
  • sourcebans.BanPlayerBySteamIDAndIP(steamID, ip, time, reason, admin, name, callback)

  • Bans a player by SteamID and IPAddress
  • 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.
  • sourcebans.CheckForBan(steamID, callback)

  • Checks to see if a SteamID is banned from the system
  • steamID: The SteamID to check
  • callback: The callback function to tell the results to
  • sourcebans.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.
  • sourcebans.GetAdmins()

  • Gets all the admins active on this server
  • sourcebans.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.
  • callback: The function to be given the table
  • sourcebans.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.
  • key: The settings key to set
  • value: The value to set the key to.
  • Acceptable keys: hostname, username, password, database, dbprefix, portnumb, serverid, website showbanreason and dogroups.
  • sourcebans.UnbanPlayerByIPAddress(ip, reason, admin)

  • Unbans a player by IPAddress. If multiple players match the IP, they will all be unbanned.
  • ip: The IPAddress to unban
  • reason: The reason they are being unbanned.
  • admin: (Optional) The admin who did the unban. Leave nil for CONSOLE.
  • sourcebans.UnbanPlayerBySteamID(steamID, reason, admin)

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

  • Converts a time into a timestring
  • time: The time in seconds
  • sourcebans.SecondsToUnit(time, unit)

  • Converts a time in seconds into units
  • time: The time
  • unit: The unit to convert the time to
  • Units:MINUTE, HOUR, DAY, WEEK, YEAR
  • sourcebans.TimestringToSeconds(str)

  • Converts a timestring into seconds
  • str: The timestring to convert
  • sourcebans.UnitToSeconds(time, unit)

  • Converts time of one unit to seconds
  • time: The time
  • unit: The unit the time is in
  • sourcebans_notify(Player, text, type, length)

  • Creates a notification on screen
  • Player: The player(s) you are sending a notification
  • Text: The text that will be in the notification (must be a string)
  • Type: The type of notification you want it to be (refer to notify enums)
  • Length: The amount of time you wish for the notification to stay on screen
  • sourcebans.getIP(Player)

  • Gets the Player’s IP without the port at the end
  • Player: The Player(s) to get IP(s) from
  • sourcebans_chatact(Player, action, target)

  • Shows the action of staff members to Administrators and above (not the gmod admin group; custom group)
  • Player: The admin that committed to the action
  • action: The action the admin committed (you must add a space at the front and end of the text!)
  • target: The player the that the admin did an action on (this is optional)
  • Example: sourcebans_chatact(Player, " respawned ", target)