From Valve Developer Community
Revision as of 10:33, 11 July 2020 by Blixibon (talk | contribs) (Revised article, updated templates, mentioned that localization *is* supported on game_text (despite comments stating otherwise))
Jump to: navigation, search
Game text.png

game_text is a point entity available in all Source games. It displays text on players' screens. This text can be defined directly in the Hammer editor (unlike the similar env_message entity which uses the titles.txt file).

In multiplayer games, the text will normally only display for the activator of the "Display" input. The "All Players" flag can be ticked in order to display on the screens of all players.

Note.png Note: If you are creating a mod with its own files and scripts, it's recommended to use the aforementioned env_message entity, which uses the titles.txt script for text parameters instead of keyvalues, allowing the text to be changed without having to recompile any maps. It also supports newlines and quotation marks, unlike regular game_text.
Tip.png Tip: Despite comments stating otherwise, game_text supports localized strings (e.g. #HL2_Chapter4_Title) in most or all Source games.
Warning.png Warning: VMFs can become corrupted when using quotation marks (") in any entity's keyvalues or I/O, so quotation marks cannot be used in the Text Message field (not even \" characters). You can use two apostrophes ('') or detailed quotes (i.e. and ) instead.
Bug.png Bug: Doesn't work in <Left 4 Dead 2> Left 4 Dead 2
Bug.png Bug: Scales incorrectly for players that have game resolution higher than 1920x1080, text will be much larger and some text will be hidden. To do: Is this Counter-Strike: Global Offensive only?

In code, it is represented by theCGameTextclass, defined in themaprules.cppfile.


Message Text <string>
Message to display onscreen. \n signifies a new line in the text.
Tip.png Tip: AddOutput message can be used to change text at runtime in older games which do not support SetText.
Bug.png Bug: Hammer will automatically change \n to /n. This can be worked around by editing the VMF with a text editor, although it will need to be changed every time after each save.
X (0 - 1.0 = left to right) (-1 centers) <string>
Horizontal position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the far left of the screen and 1 is the far right. -1 centers the text.
Y (0 - 1.0 = top to bottom) (-1 centers) <string>
Vertical position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the top of the screen and 1 is the bottom. -1 centers the text.
Text Effect <choices>
Text scan effect
Literal value Effect Description
0 Fade In/Out The whole text is faded in, and then faded out.
1 Credits To do: Unknown - seems to act like Fade In/Out. Provide description.
2 Scan Out The text is scanned in letter by letter, and the whole text is then faded out.
Color1 <color255>
The primary color used by all the text effects.
Note.png Note: The color values seem to be added to the background, so either a bright white background or black text will cause the message to be invisible.
Note.png Note: This keyvalue will default to black for entities not created in Hammer.
Color2 <color255>
The scanning color for the letter being scanned if the Text Effect keyvalue is set to Scan Out - usually a different shade of Color1.
Fade in Time (or character scan time) <string>
The time it should take for the text to fully fade in.
Fade Out Time <string>
The time it should take for the text to fade out, after the hold time has expired.
Hold Time <string>
The time the text should stay onscreen, after fading in, before it begins to fade out.
Note.png Note: This value defaults to zero for entities not created in Hammer.
Scan time (scan effect only) <string>
If the 'Text Effect' is set to Scan Out, this is the time it should take to scan out all the letters in the text.
Text Channel <choices>
You can have up to six individual game_text messages onscreen at once, stored in channels. Select which channel this text should be placed in, which will overwrite any active message already in that channel.
  • 0 : Channel 0 (unused) !FGD
  • 1 : Channel 1 (medium text size)
  • 2 : Channel 2 (small text size)
  • 3 : Channel 3 (large text size)
  • 4 : Channel 4 (medium text size)
  • 5 : Channel 5 (unused) !FGD
Master <string>
Legacy support: The name of a master entity. If the master hasn't been activated, this entity will not activate.


Name (targetname) <string>
The targetname that other entities refer to this entity by.
Entity Scripts (vscripts) <scriptlist> (in all games since <Left 4 Dead 2>)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Script think function (thinkfunction) <string> (in all games since <Left 4 Dead 2>)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.
Note.png Note: Try to avoid expensive operations in this function, as it may cause performance problems.


  •  [1] : All Players


Display the message text.
Note.png Note: If the All Players flag is not set, the player must be the !activator of this input in order for the text to be shown.
SetText <string> (in all games since <Alien Swarm>)
Set the text to display.
Tip.png Tip: In older games, AddOutput message can be used to change text, although the Display input must be fired again.
SetPosX <float> (in all games since [Portal 2])
Set the X position of the text. (0 - 1.0 = left to right) (-1 centers)
SetPosY <float> (in all games since [Portal 2])
Set the Y position of the text. (0 - 1.0 = top to bottom) (-1 centers)
SetTextColor <color255> (in all games since [Portal 2])
Set color of the front text.
SetTextColor2 <color255> (in all games since [Portal 2])
Set color of the transition text.


Removes this entity from the world.
Removes this entity and its children from the world.
Note.png Note: Entities already remove orphaned children upon being removed, but this input removes all children on the same frame, being marginally faster than Kill.
AddOutput <string>
Adds a keyvalue/output to this entity. It can be potentially very dangerous, use with care.
KV Format: <key> <value>
I/O Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything depending on the entity. Can also be invoked by firing an output that does not specify an input.
RunScriptFile <script> (in all games since <Left 4 Dead 2>)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (in all games since <Left 4 Dead 2>)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug.png Bug: In <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning.png Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction <string> (in all games since <Left 4 Dead 2>) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin <coordinates> (in all games since <Alien Swarm>) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <angles> (in all games since <Alien Swarm>) !FGD
Set this entity's angles.



OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (only in <Left 4 Dead> <Left 4 Dead 2>)
This output fires when the entity is killed and removed from the game.

See also

  • point_message - A similar entity that displays a small custom message at a specific position in the game world.
  • Customizable triggered HUD-message - How to create a new entity that is similar to game_text but can receive the message string via a triggered input.