|
VoltMod
C++23 framework for CS2 server plugins
|
Who invoked the command, and how to answer them. More...
#include <CommandBuilder.hpp>
Public Member Functions | |
| bool | IsServer () const |
| std::string | Text (std::string_view key, Tokens tokens={}) const |
| Result< Reply > | Ok (std::string_view key, Tokens tokens={}) const |
| Result< Reply > | Fail (std::string_view key, Tokens tokens={}) const |
| void | Say (std::string_view key, Tokens tokens={}) const |
| void | SayRaw (std::string_view line) const |
Public Attributes | |
| VoltMod::Player * | Player = nullptr |
| int | Slot = -1 |
| VoltMod::Translations & | Translations |
| std::function< void(const std::string &)> | Send |
Who invoked the command, and how to answer them.
A handler's first parameter. Player is null and Slot is -1 for console commands; reply helpers use the caller's language.
Definition at line 39 of file CommandBuilder.hpp.
Fail, replying with key localized for this caller.
The error keeps key in Key and the localized line in Text. Errors from other services carry only a key and are localized by dispatch.
Definition at line 18 of file CommandBuilder.cpp.
References VoltMod::Error::Code, VoltMod::Failed, VoltMod::ReadFile(), and VoltMod::Text.
|
inline |
True when the server ran the command: the server console, rcon or a cfg file.
Definition at line 51 of file CommandBuilder.hpp.
Succeed, replying with key localized for this caller.
Definition at line 13 of file CommandBuilder.cpp.
References VoltMod::ReadFile(), and VoltMod::Text.
Send one extra localized line; finish a multi-line reply with Ok or Reply::Silent.
Definition at line 25 of file CommandBuilder.cpp.
References VoltMod::ReadFile(), SayRaw(), and VoltMod::Text.
| void VoltMod::Caller::SayRaw | ( | std::string_view | line | ) | const |
Send line verbatim: an already-formatted row that has no translation of its own.
Definition at line 30 of file CommandBuilder.cpp.
References VoltMod::ReadFile(), and Send.
Referenced by Say().
| std::string VoltMod::Caller::Text | ( | std::string_view | key, |
| Tokens | tokens = {} |
||
| ) | const |
Return localized key with {token} substitution.
Definition at line 8 of file CommandBuilder.cpp.
References VoltMod::Translations::Get(), VoltMod::ReadFile(), and Slot.
| VoltMod::Player* VoltMod::Caller::Player = nullptr |
The player who typed the command, or null for console commands.
Definition at line 42 of file CommandBuilder.hpp.
Referenced by VoltMod::CommandRouter::Dispatch().
Sends a reply to chat or the console for the duration of the handler call.
Definition at line 48 of file CommandBuilder.hpp.
Referenced by SayRaw().
| int VoltMod::Caller::Slot = -1 |
Player's slot, or -1 for the console - which is also the server-language slot.
Definition at line 44 of file CommandBuilder.hpp.
Referenced by Text().
| VoltMod::Translations& VoltMod::Caller::Translations |
The plugin's translations. Get(key) with no slot resolves the server language.
Definition at line 46 of file CommandBuilder.hpp.