List of L4D2 Script Functions/ClientPrint

From Valve Developer Community
< List of L4D2 Script Functions
Revision as of 05:03, 7 October 2020 by Rectus (talk | contribs) (Created page with " == Function Description == ''' void ClientPrint(CTerrorPlayer ''player'', int ''destination'', string ''message'') ''' Print a client message. If you pass null instead of...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.


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.


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
			// Print a personalized chat message for the player
			ClientPrint(player, DirectorScript.HUD_PRINTTALK, "\x04" + "Hello " + "\x05" + player.GetPlayerName())


Print Destinations

These are the destinations that can be printed to.

Note.png 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 To do: 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. To do: The formatting is almost unreadable, and the message fades quickly.
(Unknown) 5 To do: 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