Interaction hint and keybinds
Show the “Press [E]” hint and a keybind bar with MrPoulpi UI, from the client or the server.
Two elements to show during gameplay, without taking focus: the player keeps control of their character.
Interaction hint
A “Press [E] to …” line, top left by default (Config.Layout.hint).
exports.mrpoulpi_ui:ShowHint('E', 'to open the trunk')
exports.mrpoulpi_ui:HideHint()
| Argument | Description |
|---|---|
key |
Key shown. E by default. |
text |
Text after the key. |
prefix |
Replaces “Press”. |
ShowHint also accepts a table: { key = 'G', text = 'to search', prefix = 'Hold' }. A new call replaces the hint on screen.
Example with an area
local shown = false
CreateThread(function()
while true do
local near = #(GetEntityCoords(PlayerPedId()) - vec3(215.8, -810.1, 30.7)) < 2.0
if near and not shown then
exports.mrpoulpi_ui:ShowHint('E', 'to open the garage')
shown = true
elseif not near and shown then
exports.mrpoulpi_ui:HideHint()
shown = false
end
Wait(near and 0 or 500)
end
end)
Showing the hint only when the state changes avoids sending a message to the interface every frame.
Keybind bar
A row of keys with their role, bottom right by default (Config.Layout.keybinds).
exports.mrpoulpi_ui:SetKeybinds({
{ key = 'E', label = 'Use', active = true },
{ key = 'F', label = 'Enter' },
{ key = 'G', label = 'Open' },
{ key = 'X', label = 'Cancel' }
})
exports.mrpoulpi_ui:SetKeybindActive('F', true)
exports.mrpoulpi_ui:HideKeybinds()
| Field | Description |
|---|---|
key |
Key shown. An entry without key is ignored. |
label |
Role of the key. |
active |
true highlights the key. |
SetKeybindActive(key, active) changes the highlight of a key without redrawing the bar; a missing active means true.
From the server
exports.mrpoulpi_ui:ShowHint(source, 'E', 'to talk to the seller')
exports.mrpoulpi_ui:HideHint(source)
exports.mrpoulpi_ui:SetKeybinds(source, { { key = 'E', label = 'Buy' } })
exports.mrpoulpi_ui:HideKeybinds(source)
Knowing what is shown
IsHintVisible() and IsKeybindsVisible() (client) return true when the element is shown. RefreshUI() redraws the current window, hint and bar.