Events & exports
Call these events or exports from your own resources. No changes to F5 Chat's protected files are required.
Standard chat:addMessage
Client-side example:
TriggerEvent('chat:addMessage', {
args = { 'Garage', 'Your vehicle is ready.' },
color = { 80, 180, 255 },
multiline = true
})
With two arguments, the first is the author and the second is the message. A single argument displays text without an author. A plain string is also accepted. color applies to the first argument; multiline = true preserves line breaks.
Without a recognised channel, the message appears as System in ALL. An author prefixed with OOC | selects OOC automatically.
Extended message format
Use channel, author, and text for F5 Chat's native message layout:
TriggerClientEvent('chat:addMessage', 12, {
channel = 'localchat',
author = 'Alex Morgan',
text = 'Hello! 👍',
serverId = 7,
sender = 7
})
Player 12 receives the message. serverId = 7 displays the author's ID; sender = 7 anchors a bubble to that player when nearby and visible. Neither field selects recipients.
| Field | Type | Meaning |
|---|---|---|
channel | string | system, localchat, ooc, anon, pm, me, do, radio, or server. Default: system. ALL is a view, not a delivery channel. |
text | string | Message text, including Unicode emoji and registered :emote: shortcuts. Required for the native format. |
author | string | Display name, limited to 96 UTF-16 code units. ANON discards it. Names are not resolved from a framework automatically. |
serverId | integer | Optional ID (1–2147483647) beside a non-empty author in LOCAL, OOC, PM, RADIO, ME, and DO. Does not select recipients or create bubbles. |
sender | integer | Player's server ID used to anchor LOCAL, ME, or DO bubbles. Omit for a history-only message. Bubble settings still apply. |
avatar | string | Optional Steam avatar hash: 40 lowercase hexadecimal characters, not a URL. Supported only for named OOC/LOCAL authors while SteamAvatars is enabled. |
own | boolean | true marks the message as the receiving player's own message and suppresses its unread indicator. |
alias | string | Optional ANON alias such as nira·ve: CVCV·CV, where C is one of bdfghjklmnprstvz and V is one of aeio. |
group | string | Required for RADIO: job:police, gang:ballas, faction:name, or channel:emergency. Must match the recipient's active radio group. |
groupLabel | string | RADIO label, limited to 64 UTF-16 code units; defaults to group. |
Channels disabled in Config.Channels are not displayed. ANON ignores templates and author identity; SERVER should be sent with just channel and text. Use the standard args/template format when you need text colours or formatting; those options do not style a native text payload.
Choosing recipients
chat:addMessage displays a message to the clients you target. It does not apply proximity, instance, PM routing, radio membership checks on the server, announcement ACE permissions, player cooldowns, or Discord logging. Your calling resource must enforce the required recipients and permissions. Use -1 only for messages intended for everyone.
Setting channel = 'pm' does not make a broadcast private or update the /r reply target. Setting sender creates a bubble anchor, not a proximity filter. RADIO's client-side group filter does not replace server-side recipient selection.
For a global announcement:
TriggerClientEvent('chat:addMessage', -1, {
channel = 'server',
text = 'The server will restart in 10 minutes.'
})
Blocking player messages
Before delivering a player's LOCAL, OOC, ANON, ME, DO, or SERVER message, F5 Chat triggers the server event chatMessage(source, playerName, text). Calling CancelEvent() in a handler blocks the message, and the sender sees “The message was blocked by the server.” PM and RADIO do not trigger this event. Handlers that cancel every message not starting with /, such as some versions of esx_rpchat, block normal chat; disable them as described in Installation.
AddEventHandler('chatMessage', function(source, playerName, text)
if text:find('discord.gg', 1, true) then CancelEvent() end
end)
Exports
The client export displays a message locally:
exports['f5_chat']:addMessage({
channel = 'system',
text = 'Vehicle stored. :pigeon:'
})
The server export accepts a target ID, or -1 for everyone. Omitting the target broadcasts:
exports['f5_chat']:addMessage(12, { args = { 'Garage', 'Vehicle stored.' } })
exports['f5_chat']:addMessage({ channel = 'system', text = 'Welcome!' })
Both exports['f5_chat'] and exports['chat'] expose addMessage on the client and server. The client also exposes addSuggestion(name, help, params) under both names. These aliases use the same handlers and do not duplicate messages. Start F5 Chat before resources that call its exports during startup. registerMode, registerMessageHook, and themes for the original chat are not supported; follow the Qbox installation instructions to disable qbx_chat_theme manually.
Templates and formatting
Register a template on each receiving client before using its ID:
TriggerEvent('chat:addTemplate', 'garage_notice', '<b>{0}</b>: {1} <span style="color:#8fd6ff">{{status}}</span>')
TriggerEvent('chat:addMessage', {
templateId = 'garage_notice',
args = { 'Garage', 'Your vehicle is' },
params = { status = 'ready' },
multiline = true
})
Alternatively, pass the HTML directly as template. {0}, {1}, etc. insert arguments; {{name}} inserts a named parameter. Built-in template IDs are default, defaultAlt, and print.
Basic text tags and text styles are supported, including bold, italic, underline, line breaks, and colour. Arguments and parameters remain plain text. Scripts, embedded images, custom classes, and page-layout styles are not supported.
Standard messages support ^0–^9, ^#RGB, ^#RRGGBB, ^* (bold), ^/ (italic), ^_ (underline), ^~ (strikethrough), ^= (underline and strikethrough), and ^r (reset emphasis), plus ~w~, ~r~, ~g~, ~y~, ~b~, and ~s~ colours. Legacy chatMessage(author, color, text) and chat:addMessage(author, color, text) calls are also accepted.
Command suggestions and clearing
TriggerEvent('chat:addSuggestion', '/invoice', 'Send an invoice', {
{ name = 'id', help = 'Player server ID' },
{ name = 'amount', help = 'Invoice amount' }
})
Suggestions describe commands; your resource must register and implement them. Add optional = true to an optional parameter. Also supported: chat:addSuggestions(list), chat:removeSuggestion(name), and the client export addSuggestion(name, help, params).
TriggerEvent('chat:clear') clears the receiving client's history and bubbles. From the server, use TriggerClientEvent('chat:clear', playerId) for a selected player.