VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Messages Class Reference

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)

Detailed Description

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.

Constructor & Destructor Documentation

◆ Messages() [1/2]

VoltMod::Messages::Messages ( Interfaces & interfaces,
GameEvents & events,
Translations & translations )

interfaces, events, and translations must outlive this service.

Definition at line 56 of file Messages.cpp.

Referenced by Messages(), and operator=().

◆ Messages() [2/2]

VoltMod::Messages::Messages ( const Messages & )
delete

References Messages().

Member Function Documentation

◆ Available()

Status VoltMod::Messages::Available ( ) const

NotReady when the engine's event or network message system is missing.

Definition at line 60 of file Messages.cpp.

References VoltMod::Error::NotReady().

◆ Broadcast()

void VoltMod::Messages::Broadcast ( std::string_view message,
MessageKind kind = MessageKind::Chat )

Broadcast to connected human players.

Definition at line 114 of file Messages.cpp.

References VoltMod::CenterHtml, VoltMod::HudDestination(), VoltMod::MaxPlayers, VoltMod::Render(), and SendCenterHtml().

◆ BroadcastKey()

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 144 of file Messages.cpp.

References VoltMod::MaxPlayers, and SendKey().

◆ ClearCenterHtml()

void VoltMod::Messages::ClearCenterHtml ( int slot)

Definition at line 198 of file Messages.cpp.

References SendCenterHtml().

◆ operator=()

Messages & VoltMod::Messages::operator= ( const Messages & )
delete

References VoltMod::Chat, and Messages().

◆ Send()

void VoltMod::Messages::Send ( int slot,
std::string_view message,
MessageKind kind = MessageKind::Chat )

Definition at line 103 of file Messages.cpp.

References VoltMod::CenterHtml, VoltMod::HudDestination(), VoltMod::Render(), and SendCenterHtml().

Referenced by SendKey().

◆ SendCenterHtml()

void VoltMod::Messages::SendCenterHtml ( int slot,
const std::string & html )

Write a raw center-HTML panel. Menus and CenterHtml use this path.

Definition at line 74 of file Messages.cpp.

References VoltMod::ShowSurvivalRespawnStatus::EventName, and VoltMod::IsValidSlot().

Referenced by Broadcast(), ClearCenterHtml(), and Send().

◆ SendKey()

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 139 of file Messages.cpp.

References Send().

Referenced by BroadcastKey().

◆ Shake()

void VoltMod::Messages::Shake ( int slot,
float durationSec,
float frequency,
float amplitude )

Shake slot's screen, the engine's own CUserMessageShake.

Parameters
slotRecipient player slot.
durationSechow long the shake lasts.
frequencyoscillations per second; higher reads as a rattle, lower as a sway.
amplitudehow far the view is thrown.

Definition at line 181 of file Messages.cpp.

References VoltMod::PostUserMessage().


The documentation for this class was generated from the following files: