|
VoltMod
C++23 framework for CS2 server plugins
|
Send chat, center print, center HTML, and alert messages. More...
#include <Messages.hpp>
Public Member Functions | |
| Messages (Interfaces &interfaces, GameEvents &events, Translations &translations) | |
| Messages (const Messages &)=delete | |
| Messages & | operator= (const Messages &)=delete |
| Status | Available () const |
| void | Send (int slot, std::string_view message, MessageKind kind=MessageKind::Chat) |
| void | Broadcast (std::string_view message, MessageKind kind=MessageKind::Chat) |
| void | SendKey (int slot, std::string_view key, const Tokens &tokens={}, MessageKind kind=MessageKind::Chat) |
| void | BroadcastKey (std::string_view key, const Tokens &tokens={}, MessageKind kind=MessageKind::Chat) |
| void | Shake (int slot, float durationSec, float frequency, float amplitude) |
| void | SendCenterHtml (int slot, const std::string &html) |
| void | ClearCenterHtml (int slot) |
Send chat, center print, center HTML, and alert messages.
Chat sends preserve a leading color escape or prepend the default color. Send and Broadcast send finished text; SendKey and BroadcastKey translate a key into each player's language.
Definition at line 29 of file Messages.hpp.
| VoltMod::Messages::Messages | ( | Interfaces & | interfaces, |
| GameEvents & | events, | ||
| Translations & | translations | ||
| ) |
interfaces, events, and translations must outlive this service.
Definition at line 57 of file Messages.cpp.
| Status VoltMod::Messages::Available | ( | ) | const |
NotReady when the engine's event or network message system is missing.
Definition at line 61 of file Messages.cpp.
References VoltMod::Interfaces::GameEventSystem, VoltMod::Interfaces::NetworkMessages, and VoltMod::Error::NotReady().
| void VoltMod::Messages::Broadcast | ( | std::string_view | message, |
| MessageKind | kind = MessageKind::Chat |
||
| ) |
Broadcast to connected human players.
Definition at line 115 of file Messages.cpp.
References VoltMod::MultiRecipientFilter::AddRecipient(), VoltMod::CenterHtml, VoltMod::GameEvents::GetClientLegacyListener(), VoltMod::HudDestination(), VoltMod::MaxPlayers, VoltMod::ReadFile(), VoltMod::Render(), and SendCenterHtml().
| void VoltMod::Messages::BroadcastKey | ( | std::string_view | key, |
| const Tokens & | tokens = {}, |
||
| MessageKind | kind = MessageKind::Chat |
||
| ) |
SendKey to every connected client, each in their own language.
Definition at line 147 of file Messages.cpp.
References VoltMod::GameEvents::GetClientLegacyListener(), VoltMod::MaxPlayers, VoltMod::ReadFile(), and SendKey().
Definition at line 201 of file Messages.cpp.
References VoltMod::ReadFile(), and SendCenterHtml().
Referenced by VoltMod::CenterHtmlMenu::Close(), VoltMod::CenterHtmlMenu::CloseAll(), and VoltMod::CenterHtml::Stop().
| void VoltMod::Messages::Send | ( | int | slot, |
| std::string_view | message, | ||
| MessageKind | kind = MessageKind::Chat |
||
| ) |
Definition at line 104 of file Messages.cpp.
References VoltMod::CenterHtml, VoltMod::HudDestination(), VoltMod::ReadFile(), VoltMod::Render(), and SendCenterHtml().
Write a raw center-HTML panel. Menus and CenterHtml use this path.
Definition at line 75 of file Messages.cpp.
References VoltMod::GameEvents::CreateEvent(), VoltMod::ShowSurvivalRespawnStatus::EventName, VoltMod::Interfaces::GameEventManager, VoltMod::GameEvents::GetClientLegacyListener(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by Broadcast(), ClearCenterHtml(), Send(), and VoltMod::CenterHtml::Show().
| void VoltMod::Messages::SendKey | ( | int | slot, |
| std::string_view | key, | ||
| const Tokens & | tokens = {}, |
||
| MessageKind | kind = MessageKind::Chat |
||
| ) |
Translate key into slot's language, substitute tokens, and send it.
Definition at line 142 of file Messages.cpp.
References VoltMod::Translations::Get(), VoltMod::ReadFile(), and VoltMod::Send.
Referenced by BroadcastKey().
Shake slot's screen, the engine's own CUserMessageShake.
| slot | Recipient player slot. |
| durationSec | how long the shake lasts. |
| frequency | oscillations per second; higher reads as a rattle, lower as a sway. |
| amplitude | how far the view is thrown. |
Definition at line 184 of file Messages.cpp.
References VoltMod::PostUserMessage(), and VoltMod::ReadFile().