Skip to main content

BenzyDrawText — Exports

Every export other resources can call, each with a ready-to-paste example. A prompt is purely visual: BenzyDrawText renders it on the client and never touches your game logic, so these are safe to call from anywhere.


What a prompt is

A prompt is a small card made of one or more rows. Each row is a keycap + a label ({ key = 'E', text = 'Open the door' }); a row with no key is a plain text line. Every prompt has an id — show a second prompt with a different id and both appear at once; show again with the same id to replace it. Omit the id and it uses 'default'.

A prompt stays on screen until you hide it (pass a duration to auto-hide it instead). If the resource that showed a prompt stops without hiding it, BenzyDrawText clears it for you.


Positions

position anchors a prompt to one of nine spots (default Config.Position, bottom-center):

top-left top-center top-right
center-left center center-right
bottom-left bottom-center bottom-right

Input forms

Show is deliberately forgiving — pass whichever shape suits your script:

CallWhat it shows
Show('E', 'Open the door')one keycap + label
Show('The gate is locked')a keyless plain-text line
Show({ key = 'E', text = 'Open the door' })one row as a table
Show({ { key = 'E', text = '...' }, { key = 'H', text = '...' } })several rows at once
Show({ id = 'atm', position = 'bottom-center', color = '#2ecc71', lines = { ... } })a full options table

Options-table fields (all optional):

MeaningAccepted keys
idid, name
positionposition, pos, anchor
accent colorcolor, color, accent
scalescale
auto-hide (ms)duration, length, time, timeout
rowslines (a list), or an inline key / text

Row fields — a row accepts the field names other prompt libraries use, so a row table often works unchanged:

MeaningAccepted keys
keykey, button, control
texttext, label, title, description, msg, help

Client exports

Call these from a client script to draw a prompt on that player's screen.

Show(...) — show or replace a prompt (any of the forms above). Returns the prompt id.

exports.BenzyDrawText:Show('E', 'Open the door')

ShowPrompt(...) — an alias of Show, for scripts that prefer the longer name.

Update(...) — a name for replacing a prompt you have already shown. It is the same call as Show (all the same forms), so pass the prompt's id inside the options table to replace that prompt:

exports.BenzyDrawText:Show({ id = 'atm', key = 'E', text = 'Use the ATM' })
exports.BenzyDrawText:Update({ id = 'atm', key = 'E', text = 'Enter your PIN' })

Several rows, and a keyless line:

exports.BenzyDrawText:Show({
{ key = 'E', text = 'Refuel the vehicle' },
{ key = 'H', text = 'Buy a jerry can ($40.00)' },
})
exports.BenzyDrawText:Show('The store opens at 08:00') -- plain text, no keycap

Position, accent color, scale and auto-hide:

exports.BenzyDrawText:Show({
id = 'sale', position = 'top-center', color = '#2ecc71', scale = 1.1, duration = 4000,
lines = { { key = 'E', text = 'Buy this property' } },
})

color paints a left bar on the card and tints the keycaps (any CSS color); pass false to force the neutral look even when Config.Accent is set. duration (ms) auto-hides the prompt; omit it to keep it up until you Hide it.

Hide(id) / HidePrompt(id) — take one prompt down (the default prompt if no id).

exports.BenzyDrawText:Hide() -- the default prompt
exports.BenzyDrawText:Hide('atm') -- a keyed one

HideAll() / Clear() — take every prompt down (e.g. on death or logout).

exports.BenzyDrawText:HideAll()

IsShown(id) — is a prompt (default if omitted) currently on screen? Returns a boolean.

if not exports.BenzyDrawText:IsShown('atm') then
exports.BenzyDrawText:Show({ id = 'atm', key = 'E', text = 'Use the ATM' })
end

Server exports

Call these from a server script to push a prompt to a player (or everyone). The client renders it.

Show(source, ...) — show or replace a prompt on one player by server id (the same call shapes, after source). Returns true for a valid id.

exports.BenzyDrawText:Show(source, 'E', 'Open the door')
exports.BenzyDrawText:Show(source, { id = 'atm', key = 'E', text = 'Use the ATM' })

ShowPrompt(source, ...) — an alias of the server Show.

ShowAll(...) / Broadcast(...) — show a prompt on every connected player.

exports.BenzyDrawText:ShowAll({ position = 'top-center', text = 'Server restart in 5 minutes' })

Hide(source, id) / HidePrompt(source, id) — take one prompt down on one player.

exports.BenzyDrawText:Hide(source, 'atm')

Clear(source) / ClearAll() — clear a player's prompts (or everyone's).

exports.BenzyDrawText:Clear(source)
exports.BenzyDrawText:ClearAll()

source first on the server. The single-target server exports take the player's server id as their first argument; the *All variants need no target.


Worked example: a proximity door prompt

A client resource that shows a prompt while the player is near a door and acts on the key press. The lifecycle (show when near, hide when not) is yours; BenzyDrawText just draws it.

local doorCoords = vector3(-222.0, 830.0, 30.6)
local shown = false

CreateThread(function()
while true do
local dist = #(GetEntityCoords(PlayerPedId()) - doorCoords)
if dist < 2.0 then
if not shown then
exports.BenzyDrawText:Show({ id = 'door', key = 'E', text = 'Open the door' })
shown = true
end
if IsControlJustReleased(0, 38) then -- E
TriggerServerEvent('myjob:openDoor')
end
Wait(0)
else
if shown then exports.BenzyDrawText:Hide('door'); shown = false end
Wait(500)
end
end
end)

See INTEGRATIONS.md for swapping a resource's built-in draw text over to this, and EVENTS.md for the event-based alternatives to these exports.