VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
IPluginEvents.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6#include <cstdint>
7#include <string_view>
8
9namespace VoltMod
10{
11
12/** Engine events, raised on every plugin in load order. Game thread only; a callback must not throw
13 * across the module boundary. */
15{
16 using FrameFn = void (*)(void* context);
17 using ServerStartupFn = void (*)(void* context, std::string_view mapName);
18 /** True refuses the player: later plugins are not asked, and the engine shows @p reason, which
19 * the callback fills with at most @p reasonSize bytes including the terminator. */
20 using ClientConnectingFn = bool (*)(void* context, int slot, int64_t steamId, std::string_view name, char* reason,
21 size_t reasonSize);
22 using ClientConnectedFn = void (*)(void* context, int slot, int64_t steamId, std::string_view name,
23 std::string_view address);
24 using ClientDisconnectedFn = void (*)(void* context, int slot);
25 using ClientFullyConnectedFn = void (*)(void* context, int slot);
26 using ClientSettingsChangedFn = void (*)(void* context, int slot);
27 /** True when this plugin answered it: later plugins do not see it and the engine call is blocked. */
28 using ConsoleCommandFn = bool (*)(void* context, std::string_view name, std::string_view arguments, int slot);
30 /** The next map's resource manifest, which only takes resources during this call. */
32 /** A player's command, decoded once for every plugin. */
33 using PlayerCommandFn = void (*)(void* context, int slot, const PlayerInput& input);
34 /** A custom HUD button press, raised on the frame after it arrived. @p buttonId is client text. */
35 using ButtonPressFn = void (*)(void* context, int slot, std::string_view buttonId);
36
39 /** Before the engine admits a player, and before OnClientConnected. */
48 /** Before the engine runs a player's command. Commands are decoded only while one is subscribed. */
50 /** After the engine ran it. */
53
54 /** Takes the token a subscription returned, which is never zero. Safe during a dispatch. */
55 virtual void Unsubscribe(uint64_t token) = 0;
56
57protected:
58 ~IPluginEvents() = default;
59};
60
61} // namespace VoltMod
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
void(*)(void *context, int slot) ClientFullyConnectedFn
void(*)(void *context, int slot) ClientSettingsChangedFn
virtual uint64_t OnPlayerCommandDone(PlayerCommandFn callback, void *context)=0
void(*)(void *context, int slot, std::string_view buttonId) ButtonPressFn
virtual uint64_t OnFrame(FrameFn callback, void *context)=0
void(*)(void *context, std::string_view mapName) ServerStartupFn
void(*)(void *context, int slot, int64_t steamId, std::string_view name, std::string_view address) ClientConnectedFn
virtual uint64_t OnConsoleCommand(ConsoleCommandFn callback, void *context)=0
bool(*)(void *context, std::string_view name, std::string_view arguments, int slot) ConsoleCommandFn
virtual uint64_t OnClientSettingsChanged(ClientSettingsChangedFn callback, void *context)=0
virtual uint64_t OnServerStartup(ServerStartupFn callback, void *context)=0
void(*)(void *context, CCheckTransmitInfo **infoList, int infoCount) CheckTransmitFn
void(*)(void *context, IEntityResourceManifest *manifest) BuildGameSessionManifestFn
virtual uint64_t OnClientConnected(ClientConnectedFn callback, void *context)=0
virtual uint64_t OnClientConnecting(ClientConnectingFn callback, void *context)=0
virtual uint64_t OnButtonPress(ButtonPressFn callback, void *context)=0
virtual uint64_t OnBuildGameSessionManifest(BuildGameSessionManifestFn callback, void *context)=0
void(*)(void *context) FrameFn
virtual uint64_t OnClientDisconnected(ClientDisconnectedFn callback, void *context)=0
void(*)(void *context, int slot, const PlayerInput &input) PlayerCommandFn
virtual uint64_t OnClientFullyConnected(ClientFullyConnectedFn callback, void *context)=0
virtual uint64_t OnCheckTransmit(CheckTransmitFn callback, void *context)=0
virtual void Unsubscribe(uint64_t token)=0
bool(*)(void *context, int slot, int64_t steamId, std::string_view name, char *reason, size_t reasonSize) ClientConnectingFn
void(*)(void *context, int slot) ClientDisconnectedFn
virtual uint64_t OnPlayerCommand(PlayerCommandFn callback, void *context)=0
Protobuf-free snapshot of the CUserCmd handed to CPlayer_MovementServices::RunCommand,...