BenzyChat — Exports
The exports other resources can call. There are two: one to draw a bubble on a client, one to broadcast a message from the server. Both are safe to call from anywhere — BenzyChat renders on the client and never touches your game logic.
For the many resources that already print to chat, you don't need these at all — chat:addMessage and chat:addSuggestion keep working (see EVENTS.md).
Message shape
Both exports take a table. The fields:
| Field | Meaning |
|---|---|
name | The header name (the sender). |
label | The type label shown after the name (e.g. me). Optional — omit for a name-only line. |
color | The label + accent color, any CSS color (e.g. '#3fb950'). Falls back to the theme accent. |
scope | 'local' or 'global'. A global message shows the GLOBAL tag; local (server) limits recipients to range. |
message | The text. Always rendered as plain text, so it can never inject HTML or markup. |
Client export
Call from a client script to draw a bubble on that player's screen (it also lands in their recent-message view).
AddBubble(data) — show a bubble locally.
exports.BenzyChat:AddBubble({
name = 'Radio', label = 'disp', color = '#f0a020',
scope = 'local', message = 'Unit 12, what is your status?',
})
This is exactly what BenzyChat uses for incoming messages, so a bubble you add looks identical to a chat message.
Server export
Call from a server script to push a message to players. The client renders it.
Broadcast(data) — send a message to everyone, or to players near someone.
- Global reaches every player; no
sourceneeded. - Local reaches players within range of
source(its coords anchor the range), so it needs asourceserver id. Passrangeto override the default 20m.
-- Server -> everyone
exports.BenzyChat:Broadcast({
scope = 'global', name = 'Server', label = 'info', color = '#3d9bff',
message = 'The bank heist has started downtown!',
})
-- Server -> players near a player
exports.BenzyChat:Broadcast({
scope = 'local', source = source, name = 'Megaphone', color = '#f0a020',
message = 'This is the police — come out with your hands up.', range = 30.0,
})
Broadcast returns true when the message was sent (a non-empty text, and — for local — a valid source), and false otherwise.
Worked example: a dispatch alert
A server resource that alerts nearby players when a store is robbed, with a fallback so it still works if BenzyChat isn't running.
local function alert(src, message)
if GetResourceState('BenzyChat') == 'started' then
exports.BenzyChat:Broadcast({ scope = 'local', source = src, name = 'Dispatch', label = 'leo', color = '#3d9bff', message = message })
else
TriggerClientEvent('chat:addMessage', -1, { args = { 'Dispatch', message } })
end
end
RegisterNetEvent('store:robbed', function()
alert(source, 'A robbery is in progress at the local store.')
end)
See INTEGRATIONS.md for replacing the stock chat and how other resources' output still shows, and EVENTS.md for the event-based alternatives.