CreateHudText
A line of text at a screen position, shown to the players you choose.
x and y are fractions of the screen from the top left - 0.5, 0.02 is the top centre, 0.99, 0.02 the top right with
HUD_ALIGN_RIGHT, 0.02, 0.5 the left edge halfway down - so the line lands in the same place at every resolution. The
element is shown to nobody until ShowHudText or ShowHudTextForAll; a change to its text or look is re-sent to
everyone it is shown to. A shown element survives its player’s respawns and goes with their disconnect; the mode’s
elements go with a reload. Ids start at 1; there are 4096.
Syntax
Section titled “Syntax”CreateHudText(x, y, text [, colour, scale, align])| Parameter | Type | |
|---|---|---|
x |
number | 0 .. 1 of the screen width from the left |
y |
number | 0 .. 1 of the screen height from the top |
text |
string | the line |
colour |
number | 0xRRGGBBAA (white) (optional) |
scale |
number | 1 = the HUD’s own text size; 0.5 .. 5 (optional) |
align |
number | HUD_ALIGN_LEFT (the default), HUD_ALIGN_CENTRE or HUD_ALIGN_RIGHT - which side of the line sits at x (optional) |
Returns
Section titled “Returns”number - the element’s id; nil when the ids are used up
Example
Section titled “Example”local clock
function OnGameModeInit() clock = CreateHudText(0.99, 0.02, FormatWorldTime(), COLOUR_YELLOW, 1.0, HUD_ALIGN_RIGHT) SetTimer(function() SetHudText(clock, FormatWorldTime()) end, 2000, true)end
function OnPlayerSpawn(pid) ShowHudText(clock, pid)endSee also
Section titled “See also”ShowHudText · SetHudText · DestroyHudText · GetHudTexts · the GameText and HUD group of the index
