11#include <tier0/convar.h>
18static_assert(
sizeof(
Controller) <= 104,
"Controller is a frame-local value; keep the field list tight.");
22 _pawn = entities.
Get(PlayerPawn()).
Raw();
45 return money ? money.
Account() : 0;
59 if (!
_e || !
_sys || !
_sys->Interfaces().Engine)
64 const std::string text(reason);
65 _sys->Interfaces().Engine->DisconnectClient(CPlayerSlot(_slot), NETWORK_DISCONNECT_KICKED, text.c_str());
71 if (command.empty() || command.find_first_of(
";\r\n") != std::string_view::npos)
75 return args.Tokenize(CUtlString(std::string(command).c_str())) && args.ArgC() > 0;
84 auto* cvar =
_sys->Interfaces().CVar;
85 auto* clients =
_sys->Interfaces().ServerGameClients;
86 if (!cvar || !clients)
94 Log::Warn(
"Controller: refused client command '{}'; it must be one non-empty command.", command);
98 ConCommandRef registered = cvar->FindConCommand(args.Arg(0));
99 if (registered.IsValidRef())
101 cvar->DispatchConCommand(registered, CCommandContext(CT_FIRST_SPLITSCREEN_CLIENT, CPlayerSlot(_slot)), args);
105 clients->ClientCommand(CPlayerSlot(_slot), args);
112 if (
_e &&
_sys && joinable &&
_sys->Bindings().ChangeTeam)
114 _sys->Bindings().ChangeTeam(
_e, std::to_underlying(team));
125 const auto& respawn =
_sys->Bindings().Respawn;
128 return std::unexpected(
Error::Unsupported(
"gamedata has no 'CCSPlayerController::Respawn' vtable index"));
A player's identity behind a slot: name, money, team, scoreboard row. It survives death and respawn; ...
void SetMoney(int amount) const
VoltMod::Pawn InputPawn() const
void ChangeTeam(VoltMod::Team team) const
void Kick(std::string_view reason) const
VoltMod::Pawn Pawn() const
void ExecuteCommand(std::string_view command) const
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
Entity Get(EntityRef ref)
CEntityInstance * Raw() const noexcept
A player's body: health, armor, movement, aim, weapons. The engine replaces it on every spawn; the Co...
void SetAccount(int32_t value) const
CInButtonState Buttons() const
void Warn(std::format_string< Args... > fmt, Args &&... args)
constexpr bool IsPlaying(Team team)
std::expected< void, Error > Status
static bool TokenizeOneCommand(std::string_view command, CCommand &args)
constexpr bool IsValidSlot(int slot)
static Error Unsupported(std::string detail)
static Error NotReady(std::string detail)