VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
TextMessages.hpp
Go to the documentation of this file.
1#pragma once
2
7#include <string_view>
8
9namespace VoltMod
10{
11
12/** A chat, center or alert line the server is about to send. */
14{
15 /** The line, or the `#token` the client translates, such as `#Player_Point_Award_Killed_Enemy`. */
16 std::string_view Text;
17 /** Set to send the line to nobody. */
18 bool Blocked = false;
19};
20
21/**
22 * @brief Outgoing TextMsg user messages, the game's own lines included.
23 *
24 * The hook installs on the first subscription and covers every message posted through
25 * IGameEventSystem::PostEventAbstract.
26 *
27 * @code
28 * _subs.Add(runtime.TextMessages.Before += [](VoltMod::TextMessage& text) {
29 * if (text.Text.starts_with("#Player_Point_Award_"))
30 * {
31 * text.Blocked = true;
32 * }
33 * });
34 * @endcode
35 */
37{
38public:
39 /** @p interfaces must outlive it; the Runtime declares it above. */
41 TextMessages(const TextMessages&) = delete;
43
44private:
45 LazyHook _hook;
46
47public:
49
50 /** Why messages cannot be seen: IGameEventSystem is missing. */
51 Status Available() const;
52
53private:
54 Result<Subscription> Install();
55
56 Interfaces& _interfaces;
57};
58
59} // namespace VoltMod
A multicast signal with a fixed handler signature: the one way to subscribe in VoltMod.
Definition Event.hpp:54
An engine hook that exists only while one of its events has handlers.
Definition LazyHook.hpp:30
Outgoing TextMsg user messages, the game's own lines included.
TextMessages(const TextMessages &)=delete
Status Available() const
Event< TextMessage & > Before
TextMessages & operator=(const TextMessages &)=delete
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::expected< void, Error > Status
Definition Result.hpp:67
std::expected< T, Error > Result
Definition Result.hpp:64
Centralized holder for all HL2SDK interface pointers.
std::string_view Text