Skip to main content

BenzyChat — Events

BenzyChat provides chat, so the stock chat events other resources already use keep working — you don't change anything. This file lists those, plus BenzyChat's own broadcast event, each with a ready-to-paste example.

For raising a bubble or broadcasting a message the clean way, see the exports.


Stock chat events (kept working)

BenzyChat listens for the built-in chat events, so any resource that prints to chat or registers a command suggestion behaves exactly as it did before.

chat:addMessage (client)

Print a line — it shows as a bubble. Accepts the usual shapes: { color = {r,g,b}, args = { author, message } }, { args = { message } }, or a bare string. Works both locally and pushed from the server.

-- Client -> a bubble on this player
TriggerEvent('chat:addMessage', {
color = { 90, 190, 255 },
args = { 'Dispatch', 'All units respond to a 10-90.' },
})
-- Server -> a bubble on one player (or -1 for everyone)
TriggerClientEvent('chat:addMessage', source, { args = { 'Bank', 'Your loan was approved.' } })

chat:addSuggestion (client)

Register a command in the autocomplete. name is like '/car'; help is the description. A third per-argument params table is accepted for compatibility but not rendered — the autocomplete shows the command and its help text only.

TriggerEvent('chat:addSuggestion', '/car', 'Spawn a vehicle', {
{ name = 'model', help = 'the vehicle to spawn' },
})

chat:removeSuggestion (client)

Remove a suggestion you added.

TriggerEvent('chat:removeSuggestion', '/car')

chat:clear (client)

Clear the on-screen bubbles.

TriggerEvent('chat:clear')

chat:addTemplate is accepted (so a caller never errors) but not rendered — BenzyChat draws its own bubbles rather than HTML templates.


Events you can trigger

BenzyChat:Broadcast (server → server)

A convenience wrapper around the Broadcast export, for resources that prefer events. Not a net event, so a client cannot reach it. The payload is a table.

-- Server -> everyone
TriggerEvent('BenzyChat:Broadcast', {
scope = 'global', name = 'Server', label = 'info', color = '#3d9bff',
message = 'A restart is scheduled in 5 minutes.',
})
-- Server -> players near a player (a local message)
TriggerEvent('BenzyChat:Broadcast', {
scope = 'local', source = somePlayerId, name = 'Megaphone', message = 'Move along, nothing to see here.',
})

Internal events

BenzyChat uses its own client↔server net events internally. They are validated server-side, are not part of the public API, and may change between versions — you may see BenzyChat:* events in a trace, but don't rely on them from other resources. Use the exports and the events above instead.

To show a message the supported way, use exports.BenzyChat:AddBubble (client) or exports.BenzyChat:Broadcast (server) — see the Exports documentation. Triggering the internal events directly is unsupported.