Defines the server-side cw.bans library, which keeps Steam ID and IP address bans in the database for the current schema.

cw.bans:Load reads them into cw.bans.stored, cw.bans:Add bans an identifier for a duration and kicks any matching player, and cw.bans:Remove lifts a ban.

Summary

Methods

Bans a Steam ID or IP address and kicks any matching player.
Load()server
Loads the current schema's bans from the database into cw.bans.stored.
Lifts a ban and deletes it from the database.

Methods

cw.bans:Add(identifier, duration, reason, Callback, bSaveless)

server gamemodes/catwork/gamemode/core/libraries/sv_bans.lua:147

Bans a Steam ID or IP address and kicks any matching player.

Every connected player whose Steam ID or IP matches, or who player.Find returns for the identifier, fires the PlayerBanned hook and is kicked with the reason. The ban is stored in cw.bans.stored, replacing any ban already stored for the identifier, and, unless bSaveless is set, inserted into the bans table for the current schema. For offline Steam IDs and IPs the Steam name is looked up in the players table first, so the callback runs asynchronously in that case. An identifier that is neither a Steam ID nor an IP address and matches no connected player is not banned, and the callback is called without arguments.

cw.bans:Add('STEAM_0:1:123456', 3600, 'Mic spam.', function(steamName, duration, reason)
  cw.player:NotifyAll(steamName..' has been banned for one hour.')
end)

Parameters

  • identifier String Steam ID, IP address or player name; Steam IDs are upper-cased
  • duration Number Ban length in seconds; 0 bans permanently
  • reason String optional, defaults to nil Kick and ban reason; defaults to 'Banned for an unspecified reason.'
  • Callback Function optional, defaults to nil Called as Callback(steamName, duration, reason) once the ban is stored
  • bSaveless Boolean optional, defaults to false Keep the ban in memory only and do not write it to the database

See also

Loads the current schema's bans from the database into cw.bans.stored.

Timed bans whose unban time has passed are deleted instead, both from the database and from memory, as are malformed entries.

See also

cw.bans:Remove(identifier, bSaveless)

server gamemodes/catwork/gamemode/core/libraries/sv_bans.lua:229

Lifts a ban and deletes it from the database.

Does nothing if no ban is stored under the identifier.

Parameters

  • identifier String The Steam ID or IP address the ban is stored under
  • bSaveless Boolean optional, defaults to false Only remove the ban from memory and keep the database row

See also

Defined in