15-Aug-2023
An entity to display HUD messages to the player who activated it, or all players.
Keyvalues |
OnDestroy Function ondestroyfn : Name of the function to use from already parsed .as script files when entity is destroyed (killed) in any way. If the function belongs to namespace, you must use prefix with the namespace name (e.g. mynamespace::MyFunction) for the keyvalue.
Name targetname : Set name of game_text so other entities can trigger it to display text. Every trigger use-type works uniformly. Firing on already displaying text resets it. Can be kill-targeted but already displayed text stays.
Target target : Entity to trigger when text is displayed. Trigger use-type is 'Toggle'.
Delay Before Trigger delay : Delay before trigger entity specified in "Target".
Kill Target killtarget : Entity to remove when text is displayed.
Message Text message : The message to send. Can have a maximum of 490 chars. However, Valve Hammer Editor will truncate the string to 128 if longer than that and crash if the keyvalue is displayed while having more than 127 chars. If you need a message that long, it is advised to manually assemble it once using a few trigger_changevalue entities. Using '\n', you can get into the next line.
X (0 - 1.0 = left to right) (-1 centers) x : Horizontal positioning. 0.0 to 1.0. 0.0 means left. 1.0 means right. More accurately, this defines the horizontal offset of where every line of the message starts. A value of 1.0 would literally shove the message off of the right side of the screen. '-1' centers every line depending on its length.
Y (0 - 1.0 = top to bottom) (-1 centers) y :
Vertical positioning. 0.0 to 1.0. 0.0 means top. 1.0 means bottom. '-1' centers the whole message as one, if it has multiple lines. It is advised to not center this, as it obscures the players view too much and looks shabby when drawn over the crosshair. Try values like 0.4 or 0.6 instead. Note that depending on the resolution, too high/low values may end up out of screen. Try to stay between 0.2 and 0.8. In case you ever wondered how big of an y-value equals exactly one line break, here is a list showing that in dependence on the player's resolution:
1600 x 1200: 0.016666
1280 x 960: 0.020800
1280 x 1024: 0.019550
1152 x 864: 0.023150
1024 x 768: 0.026000
800 x 600: 0.033333
720 x 576: 0.034700
640 x 480: 0.041600
960 x 600: 0.033333
1088 x 612: 0.032700
1280 x 720: 0.027800
1280 x 800: 0.025000
1600 x 900: 0.022222
Text Effect effect : Specify a text effect.
Color 1 (Add 4th number >0 for opaque) color : Color with which the text is rendered. Note that HUD messages are rendered additive. If you want your text to appear darker, make the color darker. You can add optional 4th parameter for opaque.
Color 2 (Add 4th number >0 for opaque) color2 : Another color with which the text is rendered. It comes to use with 'Credits'- and 'Scan out'-effect only. Note that HUD messages are rendered additive. If you want your text to appear darker, make the color darker. You can add optional 4th parameter for opaque.
Fade in Time (or character scan time) fadein : If the effect is 'Fade in/out' or 'Credits', this specifies the fade-in time. If the effect is set to 'Scan out', this sets the time that is taken for every single char to change its color from 'Color 2' to 'Color 1'. Fade-in time should be short.
Fade Out Time fadeout : If the effect is 'Fade in/out' or 'Credits', this specifies the fade-out time. If the effect is set to 'Scan out', this has no effect. Fade-out time should be longer than fade-in time, so the player notices that the message is going to disappear and can react by trying to read faster.
Hold Time holdtime : Time the message stays on screen after fading in, before it will being to fade out. For effect 'Scan out', this delay will start after all chars have faded in.
Scan time (scan effect only) fxtime : For effect 'Scan out', this defines the time required for a character to fade in to 'Color 2'. The next char will only start fading in as the previous one finishes. Small values like 0.01 to 0.1 seconds make sense here.
Text Channel channel : Select one of four channels to use. If a message already exists in one channel, it will be replaced.
Master master : Name of the multisource entity that (temporary) locks this game_text. If master is specified the game_text will be disabled and it will not show text. When multisource entity is triggered/being triggering by all possible inputs, the game_text will be unlocked. When multisource lost at least one input signal, the entities becomes locked again.
1 : All Players : If set, the game_text's message will be displayed to all players instead of just the activator.
2 : No console echo : If set, players will not receive a duplicate of the message in their console. Set this for messages that can be reread or are sent often to prevent console-spam and reduce network-bandwidth-usage.
The game_text's target will be triggered when the game_text entity is triggered. This is very useful when you want to use a single notification sound consistently on all your game_text entities.
Sven Co-op features a HUD monster-/player-info, which uses HUD message channel 3. Avoid using that channel for important messages. Even if you disable monster-info by setting the CVar 'mp_allowmonsterinfo' to '0', player-info will still display on that channel.
If a text message is replaced by another one because it is set to use the same channel, the time-values won't be updated, causing the new message to expire earlier than desired. Furthermore, only one text message can exist at a specific screen coordinate at a time, even if two different channels are provided.
If one line of the message is too long to fit on a player's screen, it will crash the game.