AddPlayerActionHint
Adds a line of the mode’s own to a player’s key hints in the corner, or changes it.
key is the game’s own name for the key drawn on the cap - a letter ("e", "w"), "space", "lshift", "f2",
"mouse1" (the left button), "mouse2" (the right) and the other names RegisterKeyBinding takes - or "" when
opts.binding names a key binding. text is the line as the player reads it, at most 64 characters; a text that starts with
@ is a key of the game’s own texts, which the game translates into the player’s language ("@ui_hud_inventory"). A | in a
text shows as /.
The options, all optional:
| Key | |
|---|---|
order |
the line’s place among the game’s lines and the mode’s other lines: the list grows up from the bottom of the screen, and a higher order sits lower, nearer the edge (0; -1000 .. 1000). The game’s own lines while seated are “Get up” at 90 and “Inventory” at 30: an order of 100 puts a line under them, 50 between them, 0 above them |
hold |
true draws the game’s hold mark on the key; a number of milliseconds also fills the ring around the key while the player holds it, over that long (at most 10000) |
modifier |
a second key drawn with the first, as the game’s own combinations ("lshift") |
binding |
a key binding’s name (RegisterKeyBinding): the line shows the player’s own key for it, and follows them when they bind another; while the binding has no key on their game, key is shown instead, and without one the line is not drawn |
disabled |
true draws the line faint, as the game draws its own hints for something that cannot be done right now |
The line stays until RemovePlayerActionHint or ClearPlayerActionHints takes it away, the player leaves or the mode
is reloaded. A player has at most 16 lines of the mode’s. A key name their game does not know draws no line.
The answer is true, or false and the reason: "a hint's id is 1-32 of a-z, 0-9 and _ . : -", "the key is the engine's name for a key (e, f, mouse1 ...)", "a hint needs a key, or a key binding's name", "the modifier is the engine's name for a key (lshift, lctrl ...)", "a binding name is 1-32 of a-z, 0-9 and _ . : -", "the text is empty", "the text is over 64 characters", "too many hints (16 at most a player)", "the player is not connected" or "no such player".
Syntax
Section titled “Syntax”AddPlayerActionHint(pid, id, key, text [, opts])| Parameter | Type | |
|---|---|---|
pid |
number | the player |
id |
string | the line’s id - 1 to 32 of a-z 0-9 _ . : - (capitals are lowered) |
key |
string | the key drawn, the game’s name for it ("e", "mouse1"); "" with opts.binding |
text |
string | the line, at most 64 characters, or "@" and a key of the game’s texts |
opts |
table | {order, hold, modifier, binding, disabled} - see above (optional) |
Returns
Section titled “Returns”true, or false, reason - the reason as a person reads it
Example
Section titled “Example”function OnGameModeInit() RegisterKeyBinding("rest.up", "Get up after resting", "x")end
-- /rest: the player sits down, and the corner says how to get up - on the key they use for itRegisterCommand("rest", function(pid) if PlayPlayerEmote(pid, "sit") then AddPlayerActionHint(pid, "rest.up", "", "Get up", {binding = "rest.up", order = 10}) AddPlayerActionHint(pid, "rest.pray", "r", "Pray", {hold = 1500}) endend)
function OnPlayerKeyBinding(pid, name, pressed) if name == "rest.up" and pressed then StopPlayerEmote(pid) RemovePlayerActionHint(pid, "rest.up") RemovePlayerActionHint(pid, "rest.pray") endendSee also
Section titled “See also”RemovePlayerActionHint · ClearPlayerActionHints · GetPlayerActionHints · RegisterKeyBinding · the Key hints group of the index
