Messaging and HUD
Four ways to put words in front of a player, from the chat log to the middle of the screen — and the label over their body that everyone else sees.
| Function | |
|---|---|
SendClientMessage(pid, colour, text) |
a line in one player’s chat |
SendClientMessageToAll(colour, text) |
in everyone’s |
Colours are 0xRRGGBBAA. Predefined: COLOUR_SERVER (the server’s amber), COLOUR_WHITE,
COLOUR_RED, COLOUR_GREEN, COLOUR_YELLOW.
What players type arrives as OnPlayerText (return false
to swallow a line) and /commands as OnPlayerCommandText.
GameText
Section titled “GameText”One line, big, in a serif, on the player’s screen for ms milliseconds (3000 by default,
100..60000), fading out over its last half second — “Round 3”, “You win”. A new one replaces it.
| Function | |
|---|---|
GameText(pid, text [, ms, style]) |
|
GameTextForAll(text [, ms, style]) |
style: GAMETEXT_CENTRE (0, the default), GAMETEXT_TOP, GAMETEXT_LOWER (the lower third —
a subtitle).
HUD texts
Section titled “HUD texts”A HUD text is a line at a fraction of the screen from the top left (0.5, 0.02 = top centre;
0.99, 0.02 with HUD_ALIGN_RIGHT = top right), shown to the players you choose. A change re-sends
it to them; it survives respawns and goes with the disconnect. Ids start at 1.
| Function | |
|---|---|
CreateHudText(x, y, text [, colour, scale, align]) → id | nil |
scale 1 = the HUD’s size (0.5..5); align HUD_ALIGN_LEFT (default), HUD_ALIGN_CENTRE, HUD_ALIGN_RIGHT |
DestroyHudText(id) |
|
SetHudText(id, text), GetHudText(id) |
|
SetHudTextPos(id, x, y), SetHudTextColour(id, colour), SetHudTextScale(id, scale), SetHudTextAlign(id, align) |
|
ShowHudText(id, pid), HideHudText(id, pid) |
for one player |
ShowHudTextForAll(id), HideHudTextForAll(id) |
|
IsHudTextShown(id, pid) |
|
GetHudTexts() → {id, ...} |
Both GameText and HUD texts draw under the overlay’s own windows and vanish behind the loading screen and the game’s menu.
-- a world clock in the top right corner of every screen, refreshed every 2 slocal clock = CreateHudText(0.99, 0.02, FormatWorldTime(), COLOUR_YELLOW, 1.0, HUD_ALIGN_RIGHT)SetTimer(function() SetHudText(clock, FormatWorldTime()) end, 2000, true)
function OnPlayerSpawn(pid) ShowHudText(clock, pid)endNameplates and colours
Section titled “Nameplates and colours”The nameplate is the label over a player’s body that the other clients draw; a respawn keeps it. The colour also colours the name in the Tab roster.
| Function | |
|---|---|
SetPlayerNameplate(pid, text), GetPlayerNameplate(pid) |
"" = the name again; 48 characters at most |
SetPlayerColour(pid, colour), GetPlayerColour(pid) |
0xRRGGBBAA; 0 = the default (SetPlayerColor is the same) |
| Function | |
|---|---|
SetPlayerTeam(pid, team), GetPlayerTeam(pid) |
NO_TEAM (-1) = none |
A hit between two players of one team is refused before OnPlayerDamage (the log says
“teammates”) and starts no fight. A team the clients should know too — for a marker, a colour
on the client side — goes in the player’s state bag as well.
