BenzyDrawText — Integrations
How to route another resource's on-screen prompts through BenzyDrawText, so you stop repeating the same draw-text code in every script. If a resource already sends its prompts through a single funnel (like Prompt.Set / Prompt.Clear), pointing it here is a one-line change; if it doesn't, you can call the export wherever you'd draw a prompt.
Contents
- The contract
- Swapping a built-in prompt over to it
- Using it from any resource (no funnel)
- Making it your own
The contract
BenzyDrawText exposes the same verbs on both sides:
- Client:
exports.BenzyDrawText:Show(...)/:Hide(id)— draw or clear a prompt on the calling client. - Server:
exports.BenzyDrawText:Show(source, ...)/:Hide(source, id)— push one to playersource.
A row is { key = 'E', text = '...' } (a keyless row is plain text); a prompt is one or more rows under an id. That is the whole contract — see EXPORTS.md.
Swapping a built-in prompt over to it
Many resources already funnel every hint through one function — often a NUI message like this:
-- The resource's own built-in prompt (before)
function Prompt.Set(lines)
SendNUIMessage({ action = 'prompt', show = true, lines = lines })
end
function Prompt.Clear()
SendNUIMessage({ action = 'prompt', show = false })
end
Point that funnel at BenzyDrawText and you can delete the resource's own prompt NUI (its HTML/CSS/JS for the hint) entirely:
-- After -- draw through BenzyDrawText instead
function Prompt.Set(lines)
exports.BenzyDrawText:Show({ id = 'benzyfuel', lines = lines })
end
function Prompt.Clear()
exports.BenzyDrawText:Hide('benzyfuel')
end
The lines table is already { { key = 'E', text = '...' }, ... }, which is exactly what Show accepts, so nothing else changes. Give each resource its own id ('benzyfuel', 'benzymoney', …) so two resources showing a prompt at the same time don't clobber each other.
Guard the call if BenzyDrawText is optional, and keep the old path as a fallback:
function Prompt.Set(lines)
if GetResourceState('BenzyDrawText') == 'started' then
exports.BenzyDrawText:Show({ id = 'benzyfuel', lines = lines })
else
SendNUIMessage({ action = 'prompt', show = true, lines = lines }) -- the old built-in
end
end
Using it from any resource (no funnel)
You don't need a funnel — just call the export where you would have drawn a prompt:
-- Client
exports.BenzyDrawText:Show('E', 'Pick up the item')
-- ... later
exports.BenzyDrawText:Hide()
-- Server (to a specific player)
exports.BenzyDrawText:Show(source, { id = 'atm', key = 'E', text = 'Use the ATM' })
Pass positional args or an options table — see EXPORTS.md for every export and both call styles. If BenzyDrawText might not be running, guard with GetResourceState('BenzyDrawText') == 'started' and fall back to your own hint.
Making it your own
Everything visual is in config.lua:
Config.Position— the default anchor (one of nine); a caller can override it per prompt.Config.Scale— an overall size multiplier.Config.Accent— an optional default accent color; a caller can pass its own so its prompts match its brand.Config.Style— the card + keycap theme (background, text, radius, font size, keycap colors).
For deeper visual changes the prompt markup + styles live in html/ — it's a small, self-contained layer with no dependencies.