Skip to content

API reference

The public API in CS2-SimpleAdminApi/, generated from the source at build time: signatures as written, with their /// documentation. Get the API with the simpleadmin:api plugin capability; see Modules for a working module. Menus are passed around as object: create them with the API and pass them back to it (AddMenuOption, AddSubMenu, OpenMenu).

“Used by” names the modules in this repository that call a member, as examples to read.

Events

event Action? OnSimpleAdminReady

Used by: FunCommands, ExampleModule

event Action<PlayerInfo, PlayerInfo?, PenaltyType, string, int, int?, int?>? OnPlayerPenaltied

Event fired when a player receives a penalty.

Used by: BanSoundModule, ExampleModule

event Action<SteamID, PlayerInfo?, PenaltyType, string, int, int?, int?>? OnPlayerPenaltiedAdded

Event fired when a penalty is added to a player by SteamID.

Used by: ExampleModule

event Action<string, string?, bool, object>? OnAdminShowActivity

Event to show admin activity messages.

Used by: RedisInform

event Action<int, bool>? OnAdminToggleSilent

Event fired when an admin toggles silent mode.

Used by: StealthModule

Players and penalties

PlayerInfo GetPlayerInfo(CCSPlayerController player)

Gets player information associated with the specified player controller.

player
The player controller.

Used by: FunCommands, ExampleModule

Dictionary<PenaltyType, List<(DateTime EndDateTime, int Duration, bool Passed)>> GetPlayerMuteStatus(CCSPlayerController player)

Returns mute-related penalties for the specified player.

player
The player controller.
void IssuePenalty(CCSPlayerController player, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1)

Issues a penalty to a player controller with specified type, reason, and optional duration.

Used by: AntiDLL, ExampleModule

void IssuePenalty(SteamID steamid, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1)

Issues a penalty to a player identified by SteamID with specified type, reason, and optional duration.

Used by: AntiDLL, ExampleModule

TargetResult? GetTarget(CommandInfo command)

Gets target players from command

Used by: FunCommands

List<CCSPlayerController> GetValidPlayers()

Returns the list of current valid players, available to call from other plugins.

Used by: FunCommands, ExampleModule

Server and database

string GetConnectionString()

Returns the database connection string used by the plugin.

Used by: ExampleModule

string GetServerAddress()

Returns the configured server IP address with port.

Used by: ExampleModule

int? GetServerId()

Returns the internal server ID assigned in the plugin's database.

Used by: ExampleModule

Messages, logging and silent admins

void LogCommand(CCSPlayerController? caller, string command)

Logs a command invoked by a caller with the command string.

Used by: FunCommands

void LogCommand(CCSPlayerController? caller, CommandInfo command)

Logs a command invoked by a caller with the command info object.

Used by: FunCommands

void ShowAdminActivity(string messageKey, string? callerName = null, bool dontPublish = false, params object[] messageArgs)

Shows an admin activity message, optionally suppressing broadcasting.

Used by: FunCommands, RedisInform

void ShowAdminActivityTranslated(string translatedMessage, string? callerName = null, bool dontPublish = false)

Shows an admin activity message with a custom translated message (for modules with their own localizer).

translatedMessage
Already translated message to display to players.
callerName
Name of the admin executing the action (optional).
dontPublish
If true, won't trigger publish events.
void ShowAdminActivityLocalized(object moduleLocalizer, string messageKey, string? callerName = null, bool dontPublish = false, params object[] messageArgs)

Shows an admin activity message using module's localizer for per-player language support. This method sends messages in each player's configured language.

moduleLocalizer
The module's IStringLocalizer instance.
messageKey
The translation key from the module's lang files.
callerName
Name of the admin executing the action (optional).
dontPublish
If true, won't trigger publish events.
messageArgs
Arguments to format the localized message.

Used by: FunCommands

bool IsAdminSilent(CCSPlayerController player)

Returns true if the specified admin player is in silent mode (not broadcasting activity).

Used by: FunCommands, StealthModule, ExampleModule

HashSet<int> ListSilentAdminsSlots()

Returns a set of player slots representing admins currently in silent mode.

Used by: StealthModule

Commands

void RegisterCommand(string name, string? description, CommandInfo.CommandCallback callback)

Registers a new command with the specified name, description, and callback.

Used by: FunCommands

void UnRegisterCommand(string name)

Unregisters an existing command by its name.

Used by: FunCommands

Types

class MenuContext

Provides contextual information about a menu to its factory function. This eliminates the need to duplicate category IDs and menu titles when creating menus.

MemberDescription
string CategoryIdThe category ID this menu belongs to (e.g., "fun", "players"). Used for automatic "Back" button navigation.
string MenuIdThe unique identifier for this menu within its category.
string MenuTitleThe display title of the menu (from registration).
string? PermissionThe permission required to access this menu (if any).
string? CommandNameThe command name for permission override checking (if any).
MenuContext(string categoryId, string menuId, string menuTitle, string? permission = null, string? commandName = null)Creates a new MenuContext with the specified values.
CategoryId = categoryId
MenuId = menuId
MenuTitle = menuTitle
Permission = permission
CommandName = commandName

CS2-SimpleAdminApi/MenuContext.cs

class PlayerInfo

PlayerInfo(
  int? userId,
  int slot,
  SteamID steamId,
  string name,
  string? ipAddress,
  int totalBans = 0,
  int totalMutes = 0,
  int totalGags = 0,
  int totalSilences = 0,
  int totalWarns = 0
)
MemberDescription
int? UserId
int Slot
SteamID SteamId
string Name
string? IpAddress
int TotalBans
int TotalMutes
int TotalGags
int TotalSilences
int TotalWarns
bool WaitingForKick
List<(ulong SteamId, string PlayerName)> AccountsAssociated
DiePosition? DiePosition
bool IsLoaded

CS2-SimpleAdminApi/PlayerInfo.cs

Source: CS2-SimpleAdminApi/ICS2-SimpleAdminApi.cs