VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
ServerCommand.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
VoltMod/Engine/EngineTypes.hpp
>
4
#include <functional>
5
#include <memory>
6
#include <string_view>
7
8
namespace
VoltMod
9
{
10
11
/**
12
* @brief RAII server console command: registers a tier1 ConCommand on construction and
13
* unregisters on destruction.
14
*
15
* Use this for server-console, RCON, cfg, and loosely coupled automation surfaces. Invoke
16
* commands through @ref ConVars::ExecuteServerCommand. Prefer ServiceExchange
17
* when two plugins need a typed, versioned contract.
18
*
19
* The handler runs on the game thread. Construct only while the plugin is loaded (ICvar must be
20
* live); typically a manager member, so destruction on unload unregisters it.
21
*/
22
class
ServerCommand
23
{
24
public
:
25
/** @p slot is the player who typed it in their own console, or -1 for the server. */
26
using
Handler
= std::function<void(
const
CCommand& args,
int
slot)>;
27
28
/** Runs for the server console, RCON and cfg files; with @p playersCanRun, also from a
29
* player's own console. Otherwise the engine refuses a player before the handler runs. */
30
ServerCommand
(std::string_view name, std::string_view helpText,
Handler
handler,
bool
playersCanRun =
false
);
31
~ServerCommand
();
32
ServerCommand
(
const
ServerCommand
&) =
delete
;
33
ServerCommand
&
operator=
(
const
ServerCommand
&) =
delete
;
34
35
private
:
36
struct
Impl
;
// tier1's ConCommand, kept out of this header
37
std::unique_ptr<Impl> _impl;
38
};
39
40
}
// namespace VoltMod
EngineTypes.hpp
VoltMod::ServerCommand::ServerCommand
ServerCommand(const ServerCommand &)=delete
VoltMod::ServerCommand::Handler
std::function< void(const CCommand &args, int slot)> Handler
Definition
ServerCommand.hpp:26
VoltMod::ServerCommand::~ServerCommand
~ServerCommand()
VoltMod::ServerCommand::operator=
ServerCommand & operator=(const ServerCommand &)=delete
VoltMod::ServerCommand::ServerCommand
ServerCommand(std::string_view name, std::string_view helpText, Handler handler, bool playersCanRun=false)
Definition
ServerCommand.cpp:35
VoltMod
Definition
Options.hpp:13
VoltMod::ServerCommand::Impl
Definition
ServerCommand.cpp:10
include
VoltMod
Engine
Server
ServerCommand.hpp
Generated by
1.15.0