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
3
#include <
VoltMod/Core/Result.hpp
>
4
#include <
VoltMod/Core/Signals/Event.hpp
>
5
#include <
VoltMod/Core/Signals/LazyHook.hpp
>
6
#include <
VoltMod/Engine/Interfaces.hpp
>
7
#include <string_view>
8
9
namespace
VoltMod
10
{
11
12
/** A chat, center or alert line the server is about to send. */
13
struct
TextMessage
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
*/
36
class
TextMessages
37
{
38
public
:
39
/** @p interfaces must outlive it; the Runtime declares it above. */
40
explicit
TextMessages
(
Interfaces
&
interfaces
);
41
TextMessages
(
const
TextMessages
&) =
delete
;
42
TextMessages
&
operator=
(
const
TextMessages
&) =
delete
;
43
44
private
:
45
LazyHook
_hook;
46
47
public
:
48
Event<TextMessage&>
Before
;
49
50
/** Why messages cannot be seen: IGameEventSystem is missing. */
51
Status
Available
()
const
;
52
53
private
:
54
Result<Subscription>
Install();
55
56
Interfaces
& _interfaces;
57
};
58
59
}
// namespace VoltMod
Event.hpp
Interfaces.hpp
LazyHook.hpp
Result.hpp
VoltMod::Event
A multicast signal with a fixed handler signature: the one way to subscribe in VoltMod.
Definition
Event.hpp:54
VoltMod::LazyHook
An engine hook that exists only while one of its events has handlers.
Definition
LazyHook.hpp:30
VoltMod::TextMessages
Outgoing TextMsg user messages, the game's own lines included.
Definition
TextMessages.hpp:37
VoltMod::TextMessages::TextMessages
TextMessages(const TextMessages &)=delete
VoltMod::TextMessages::Available
Status Available() const
Definition
TextMessages.cpp:53
VoltMod::TextMessages::Before
Event< TextMessage & > Before
Definition
TextMessages.hpp:48
VoltMod::TextMessages::operator=
TextMessages & operator=(const TextMessages &)=delete
VoltMod
Definition
Options.hpp:13
VoltMod::ReadFile
static std::string ReadFile(const std::filesystem::path &path)
Definition
Loader.cpp:56
VoltMod::Status
std::expected< void, Error > Status
Definition
Result.hpp:67
VoltMod::Result
std::expected< T, Error > Result
Definition
Result.hpp:64
VoltMod::Interfaces
Centralized holder for all HL2SDK interface pointers.
Definition
Interfaces.hpp:19
VoltMod::TextMessage
Definition
TextMessages.hpp:14
VoltMod::TextMessage::Text
std::string_view Text
Definition
TextMessages.hpp:16
VoltMod::TextMessage::Blocked
bool Blocked
Definition
TextMessages.hpp:18
include
VoltMod
Hooks
TextMessages.hpp
Generated by
1.9.8