VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::ServerCommand Class Reference

RAII server console command: registers a tier1 ConCommand on construction and unregisters on destruction. More...

#include <ServerCommand.hpp>

Classes

struct  Impl
 

Public Types

using Handler = std::function< void(const CCommand &args, int slot)>
 

Public Member Functions

 ServerCommand (std::string_view name, std::string_view helpText, Handler handler, bool playersCanRun=false)
 
 ~ServerCommand ()
 
 ServerCommand (const ServerCommand &)=delete
 
ServerCommand & operator= (const ServerCommand &)=delete
 

Detailed Description

RAII server console command: registers a tier1 ConCommand on construction and unregisters on destruction.

Use this for server-console, RCON, cfg, and loosely coupled automation surfaces. Invoke commands through ConVars::ExecuteServerCommand. Prefer ServiceExchange when two plugins need a typed, versioned contract.

The handler runs on the game thread. Construct only while the plugin is loaded (ICvar must be live); typically a manager member, so destruction on unload unregisters it.

Definition at line 22 of file ServerCommand.hpp.

Member Typedef Documentation

◆ Handler

slot is the player who typed it in their own console, or -1 for the server.

Definition at line 26 of file ServerCommand.hpp.

Constructor & Destructor Documentation

◆ ServerCommand() [1/2]

VoltMod::ServerCommand::ServerCommand ( std::string_view  name,
std::string_view  helpText,
Handler  handler,
bool  playersCanRun = false 
)

Runs for the server console, RCON and cfg files; with playersCanRun, also from a player's own console. Otherwise the engine refuses a player before the handler runs.

Definition at line 35 of file ServerCommand.cpp.

◆ ~ServerCommand()

VoltMod::ServerCommand::~ServerCommand ( )
default

◆ ServerCommand() [2/2]

VoltMod::ServerCommand::ServerCommand ( const ServerCommand &  )
delete

Member Function Documentation

◆ operator=()

ServerCommand & VoltMod::ServerCommand::operator= ( const ServerCommand &  )
delete

The documentation for this class was generated from the following files: