Difference between revisions of "UTIL SayTextAll"

From Valve Developer Community
Jump to: navigation, search
(Created page.)
 
(Improved examples.)
Line 5: Line 5:
  
 
==Examples==
 
==Examples==
 +
Tells everyone in chat that the server will restart in <code>sv_restart_server_delay</code> (not defined for concisement reasons) seconds.
  
 
  char* NotifyRestartText = "";
 
  char* NotifyRestartText = "";
 
  V_snprintf(NotifyRestartText, sizeof(NotifyRestartText), "This server will restart in %f seconds.", sv_restart_server_delay.GetFloat());
 
  V_snprintf(NotifyRestartText, sizeof(NotifyRestartText), "This server will restart in %f seconds.", sv_restart_server_delay.GetFloat());
  UTIL_SayTextAll(NotifyRestartText, UTIL_GetCommandClient(), true);
+
  UTIL_SayTextAll(NotifyRestartText, UTIL_GetCommandClientIndex(), true);
 +
 
 +
A message that emits to all players' console output.
 +
UTIL_SayTextAll("I'm a console message that is sent to everyone!", UTIL_GetCommandClient(), false);

Revision as of 22:10, 22 July 2021

A UTIL wrapper function for UTIL_SayTextFilter that sends a message to all players.

Usage

void UTIL_SayTextAll(const char *pText, CBasePlayer *pPlayer, bool bChat)

Examples

Tells everyone in chat that the server will restart in sv_restart_server_delay (not defined for concisement reasons) seconds.

char* NotifyRestartText = "";
V_snprintf(NotifyRestartText, sizeof(NotifyRestartText), "This server will restart in %f seconds.", sv_restart_server_delay.GetFloat());
UTIL_SayTextAll(NotifyRestartText, UTIL_GetCommandClientIndex(), true);

A message that emits to all players' console output.

UTIL_SayTextAll("I'm a console message that is sent to everyone!", UTIL_GetCommandClient(), false);