Left 4 Dead 2/Scripting/Script Functions/ClientPrint
< Left 4 Dead 2 | Scripting | Script Functions
This article needs more links to other articles to help integrate it into the encyclopedia. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024
January 2024
Function Description
void ClientPrint(CTerrorPlayer player, int destination, string message)
Print a client message. If you pass null instead of a valid player, the message will be sent to all clients.
Printing to the chat box supports using a limited amount of color codes for custom colors. To use them add the characte before the colored text, either as a \x
escape code into the string, or as a char with the integer value.
Parameters
Type | Name | Description |
---|---|---|
CTerrorPlayer | player | The handle of the player who receives the message or null for everyone.
|
int | destination | The destination to print to. See Print Destinations for a list of destinations. |
string | message | The message to print. |
Example
function ConsolePrint()
{
// Print a chat message visible to everyone
ClientPrint(null, DirectorScript.HUD_PRINTTALK, "\x03" + "Hello everyone!")
local player = null
// Iterate through every player
while(player = Entities.FindByClassname(player, "player"))
{
// Only print to human controlled survivors and special infected
if(!IsPlayerABot(player))
{
// Print a personalized chat message for the player
ClientPrint(player, DirectorScript.HUD_PRINTTALK, "\x04" + "Hello " + "\x05" + player.GetPlayerName())
}
}
}
ConsolePrint()
Print Destinations
These are the destinations that can be printed to.
Note: The enumerations are only available in the Director scope, to access them outside of Director or mutation scripts, prefix the enumearion with
DirectorScript
. fore example DirectorScript.HUD_PRINTTALK
Enumeration | Value | Description |
---|---|---|
HUD_PRINTNOTIFY | 1 | Todo: Prints the message to console, sets some kind of notify flag.
|
HUD_PRINTCONSOLE | 2 | Prints the message to console. |
HUD_PRINTTALK | 3 | Prints the message to the chat box. Supports custom color codes. |
HUD_PRINTCENTER | 4 | Prints the message to the center of the screen. Todo: The formatting is almost unreadable, and the message fades quickly.
|
(Unknown) | 5 | Todo: Prints the message to the chat box with an orange color by default. Supports custom color codes.
|
Color Codes
Color | Value |
---|---|
Beige (default color) | \x01
|
Bright green | \x03
|
Orange | \x04
|
Olive green | \x05
|