This article's documentation is for anything that uses the Source engine. Click here for more information.

Env message: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(raw; needs cleanup)
 
(position in the world irrelevant so it's logical entity)
 
(52 intermediate revisions by 29 users not shown)
Line 1: Line 1:
{{cleanup}}
{{LanguageBar|title = env_message}}
env_message


An entity that draws a text message on player's HUDs.
[[File:env_message.png|left|link=]]
{{CD|CMessage|file1=EnvMessage.cpp}}
{{This is a|logical entity|name=env_message}} It draws a text message on player HUDs, predefined in the <code>/scripts/titles.txt</code> file.
{{bug|hidetested=1|Does not function in {{css}} and {{l4d2}}.}}
{{toc-right}}


KEYS
== Keyvalues ==
{{KV Targetname}}
{{KV|Message Text|intn=message|string|Message to be shown. See above.}}
{{KV|Sound Effect|intn=messagesound|sound|When the message is shown, this sound effect will be played, originating from this entity.}}
{{KV|Volume 0-10|intn=messagevolume|string|Volume of the sound effect.}}
{{KV|Sound Radius|intn=messageattenuation|choices|How big the radius of the sound is.
:*0: Small Radius
:*1: Medium Radius
:*2: Large  Radius
:*3: Play Everywhere}}


Name targetname <target_source> The name that other entities refer to this entity by.
== Flags ==
{{fl|1|Play Once}}
{{fl|2|All Clients}}


Message Text message <string>
== Inputs ==
{{I|ShowMessage|Shows the message and plays the sound.}}


spawnflags spawnflags <flags>
== Outputs ==
{{O|OnShowMessage|Fired when the message is activated.}}


Sound Effect messagesound <sound> When the message is shown, this sound effect will be played, originating from this entity.
== File format ==
Each message entry in titles.txt follows a similar structure as other Valve text files. Example: <code>Title { Text Value }</code>. The message can reference a [[VGUI_Documentation#Localization|localized]] string prefixed with <code>#</code>.


Volume 0-10 messagevolume <string> Volume of the sound effect.
This text can be formatted in many different ways, according to the syntax provided. The <code>resource/clientscheme.res</code> is responsible for the font family, size and weight of the message. To change the size find <code>CenterPrintText</code> in the res file.


Sound Radius messageattenuation <choices>
Variables can be defined which will affect all the messages below them, until overwritten with another value.


{| class="standard-table"
|-
! Varaible !! Parameters !! Description
|-
| $position || float, float || Position of the text onscreen, represented as a range from 0-1. The first float is horizontal, with 0 being the left; the second is vertical, with 0 being the top. -1 is centered. {{bug|In most games, messages are constrained to being displayed in a 4:3 area aligned to the left side of the screen, making approximately the entire right third of the screen in widescreen mode unusable.}} {{modernFix|This is fixed in newer versions of {{hl2|4}} and {{portal|4}}, and can be fixed in mods for other games by increasing the width of the <code>HudMessage</code> panel in <code>scripts/hudlayout.res</code>.}}
|-
| $effect || integer || How it is displayed. 0 is fade in/fade out, 1 is flickery credits, 2 is write out
|-
| $fxtime || float || When using the write out effect, this is the amount of time the highlight lags behind the leading edge of the text
|-
| $color || R G B || Color of the text as red-green-blue between 0-255
|-
| $color2 || R G B || Highlight color used for the write out effect as characters are appearing
|-
| $fadein || float || Fade in time of message or each character in seconds
|-
| $fadeout || float || Fade out time in seconds
|-
| $holdtime || float || How long to wait after fade in before fade out
|-
| $boxsize || float || If non-zero, adds a background behind the text (like the HL2 'Saved' message). The size of the border is calculated as this value multiplied by the font height.
|-
| $boxcolor || R G B A || Color and opacity of the text background
|-
| $clearmessage || string || Clears any existing message of the given name upon display. Set to 0 to disable.
|}


INPUTS
If you make a standalone modification you can alter this file with your own entries. The default titles from HL2 are listed below:


Kill Removes this entity from the world.
{| class="standard-table"
! Message Value !! Printed Text
|-
|CR1 || Testing 1
|-
|CR2 || Testing 2
|-
|CR3 || Testing 3
|-
|GAMEOVER_ALLY || ASSIGNMENT: TERMINATED


KillHierarchy Removes this entity and all its children from the world.
SUBJECT: FREEMAN


AddOutput <string> Adds an entity I/O connection to this entity. Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>. Very dangerous, use with care.
REASON: FAILURE TO PRESERVE MISSION-CRITICAL PERSONNEL
|-
|GAMEOVER_OBJECT || ASSIGNMENT: TERMINATED


FireUser1 Causes this entity's OnUser1 output to be fired.
SUBJECT: FREEMAN


FireUser2 Causes this entity's OnUser2 output to be fired.
REASON: FAILURE TO PRESERVE MISSION-CRITICAL RESOURCES
|-
|GAMEOVER_TIMER || ASSIGNMENT: TERMINATED


FireUser3 Causes this entity's OnUser3 output to be fired.
SUBJECT: FREEMAN


FireUser4 Causes this entity's OnUser4 output to be fired.
REASON: FAILURE TO PREVENT TIME-CRITICAL SEQUENCE
|-
|GAMEOVER_STUCK || ASSIGNMENT: TERMINATED


ShowMessage Shows the message and plays the sound.
SUBJECT: FREEMAN


REASON: DEMONSTRATION OF EXCEEDINGLY POOR JUDGMENT
|-
|CHAPTER1_TITLE || POINT INSERTION
|-
|CHAPTER2_TITLE || "A RED LETTER DAY"
|-
|CHAPTER3_TITLE || ROUTE KANAL
|-
|CHAPTER4_TITLE || WATER HAZARD
|-
|CHAPTER5_TITLE || BLACK MESA EAST
|-
|CHAPTER6_TITLE || "WE DON'T GO TO RAVENHOLM..."
|-
|CHAPTER7_TITLE || HIGHWAY 17
|-
|CHAPTER8_TITLE || SANDTRAPS
|-
|CHAPTER9_TITLE || NOVA PROSPEKT
|-
|CHAPTER9A_TITLE || ENTANGLEMENT
|-
|CHAPTER10_TITLE || ANTICITIZEN ONE
|-
|CHAPTER11_TITLE || "FOLLOW FREEMAN!"
|-
|CHAPTER12_TITLE || OUR BENEFACTORS
|-
|CHAPTER13_TITLE || DARK ENERGY
|-
|GAMESAVED || Saved...
|-
|GAMETITLE || Half-Life
|}


OUTPUTS
==Files==
# <code>scripts/titles[[.txt]]</code>


OnUser1 Fired in response to FireUser1 input.
== See also ==
*{{ent|game_text}} - Similar entity that lets you define a text directly in the Hammer editor.
*{{ent|env_hudhint}} - Similar entity that displays predefined HUD hints about controls and other things.


OnUser2 Fired in response to FireUser2 input.
[[Category:GUI Entities]]


OnUser3 Fired in response to FireUser3 input.
[[Category:Plain text formats]]
 
OnUser4 Fired in response to FireUser4 input.
 
OnShowMessage Fired when the message is activated.

Latest revision as of 04:26, 29 April 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)
Env message.png
C++ Class hierarchy
CMessage
CPointEntity
CBaseEntity
C++ EnvMessage.cpp

env_message is a logical entity available in all Source Source games. It draws a text message on player HUDs, predefined in the /scripts/titles.txt file.

Icon-Bug.pngBug:Does not function in Counter-Strike: Source and Left 4 Dead 2.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Message Text (message) <string>
Message to be shown. See above.
Sound Effect (messagesound) <sound>
When the message is shown, this sound effect will be played, originating from this entity.
Volume 0-10 (messagevolume) <string>
Volume of the sound effect.
Sound Radius (messageattenuation) <choices>
How big the radius of the sound is.
  • 0: Small Radius
  • 1: Medium Radius
  • 2: Large Radius
  • 3: Play Everywhere

Flags

Play Once : [1]
All Clients : [2]

Inputs

ShowMessage
Shows the message and plays the sound.

Outputs

OnShowMessage
Fired when the message is activated.

File format

Each message entry in titles.txt follows a similar structure as other Valve text files. Example: Title { Text Value }. The message can reference a localized string prefixed with #.

This text can be formatted in many different ways, according to the syntax provided. The resource/clientscheme.res is responsible for the font family, size and weight of the message. To change the size find CenterPrintText in the res file.

Variables can be defined which will affect all the messages below them, until overwritten with another value.

Varaible Parameters Description
$position float, float Position of the text onscreen, represented as a range from 0-1. The first float is horizontal, with 0 being the left; the second is vertical, with 0 being the top. -1 is centered.
Icon-Bug.pngBug:In most games, messages are constrained to being displayed in a 4:3 area aligned to the left side of the screen, making approximately the entire right third of the screen in widescreen mode unusable.  [todo tested in ?]
Note.pngFix:This is fixed in newer versions of Half-Life 2 Half-Life 2 and Portal Portal, and can be fixed in mods for other games by increasing the width of the HudMessage panel in scripts/hudlayout.res.
$effect integer How it is displayed. 0 is fade in/fade out, 1 is flickery credits, 2 is write out
$fxtime float When using the write out effect, this is the amount of time the highlight lags behind the leading edge of the text
$color R G B Color of the text as red-green-blue between 0-255
$color2 R G B Highlight color used for the write out effect as characters are appearing
$fadein float Fade in time of message or each character in seconds
$fadeout float Fade out time in seconds
$holdtime float How long to wait after fade in before fade out
$boxsize float If non-zero, adds a background behind the text (like the HL2 'Saved' message). The size of the border is calculated as this value multiplied by the font height.
$boxcolor R G B A Color and opacity of the text background
$clearmessage string Clears any existing message of the given name upon display. Set to 0 to disable.

If you make a standalone modification you can alter this file with your own entries. The default titles from HL2 are listed below:

Message Value Printed Text
CR1 Testing 1
CR2 Testing 2
CR3 Testing 3
GAMEOVER_ALLY ASSIGNMENT: TERMINATED

SUBJECT: FREEMAN

REASON: FAILURE TO PRESERVE MISSION-CRITICAL PERSONNEL

GAMEOVER_OBJECT ASSIGNMENT: TERMINATED

SUBJECT: FREEMAN

REASON: FAILURE TO PRESERVE MISSION-CRITICAL RESOURCES

GAMEOVER_TIMER ASSIGNMENT: TERMINATED

SUBJECT: FREEMAN

REASON: FAILURE TO PREVENT TIME-CRITICAL SEQUENCE

GAMEOVER_STUCK ASSIGNMENT: TERMINATED

SUBJECT: FREEMAN

REASON: DEMONSTRATION OF EXCEEDINGLY POOR JUDGMENT

CHAPTER1_TITLE POINT INSERTION
CHAPTER2_TITLE "A RED LETTER DAY"
CHAPTER3_TITLE ROUTE KANAL
CHAPTER4_TITLE WATER HAZARD
CHAPTER5_TITLE BLACK MESA EAST
CHAPTER6_TITLE "WE DON'T GO TO RAVENHOLM..."
CHAPTER7_TITLE HIGHWAY 17
CHAPTER8_TITLE SANDTRAPS
CHAPTER9_TITLE NOVA PROSPEKT
CHAPTER9A_TITLE ENTANGLEMENT
CHAPTER10_TITLE ANTICITIZEN ONE
CHAPTER11_TITLE "FOLLOW FREEMAN!"
CHAPTER12_TITLE OUR BENEFACTORS
CHAPTER13_TITLE DARK ENERGY
GAMESAVED Saved...
GAMETITLE Half-Life

Files

  1. scripts/titles.txt

See also

  • game_text - Similar entity that lets you define a text directly in the Hammer editor.
  • env_hudhint - Similar entity that displays predefined HUD hints about controls and other things.