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

◆ Messages() [2/2]

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

Member Function Documentation

◆ Available()

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().

◆ Broadcast()

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

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

References VoltMod::GameEvents::GetClientLegacyListener(), VoltMod::MaxPlayers, VoltMod::ReadFile(), and SendKey().

◆ ClearCenterHtml()

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

◆ operator=()

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

◆ Send()

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

◆ SendCenterHtml()

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

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

References VoltMod::Translations::Get(), VoltMod::ReadFile(), and VoltMod::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 184 of file Messages.cpp.

References VoltMod::PostUserMessage(), and VoltMod::ReadFile().


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