Exports
Exports documented currently for Wasabi Chat (wasabi_chat).
Every export except
openWristLinkandcloseWristLinkis also available asexports['chat'], so scripts made for the stock chat keep working.
Client Exportsβ
Messagesβ
sendMessage
Show a message in the local player's chat only. It is not saved on the server and does not fire wasabi_chat:messageSent.
local success, reason = exports['wasabi_chat']:sendMessage(sender, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
sender | string|table | Yes | A sender ID from registerSender, or a table { name, color?, channel?, banner? }. See the server sendMessage. |
text | string | Yes | Message text. |
opts | table | No | { color?, image?, banner?, channel? }. Same as the server sendMessage. |
Returns: boolean, string? β true when shown, otherwise false and a reason (disabled, invalid_sender, unknown_sender, sender_disabled, invalid_name, invalid_color, invalid_channel, invalid_text, invalid_options).
registerSender
Save a sender under an ID on this client, so you can pass the ID instead of a table.
local success, reason = exports['wasabi_chat']:registerSender(id, sender)
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Letters, numbers, _ and -, up to 64 characters. |
sender | table | Yes | { name, color?, channel?, banner? }. |
Returns: boolean, string? β true when saved, otherwise false and a reason.
removeSender
Remove a sender saved on this client.
local removed = exports['wasabi_chat']:removeSender(id)
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The sender ID. |
Returns: boolean β true if the sender existed.
Chatβ
setChatHidden
Hide or show the chat, for example while your own UI is open. Hiding also closes the chat input and Wrist Link.
local success = exports['wasabi_chat']:setChatHidden(hidden)
| Parameter | Type | Required | Description |
|---|---|---|---|
hidden | boolean | Yes | true to hide, false to remove your hide. |
Returns: boolean, string? β true, or false, 'invalid_value'.
Each resource has its own hide. The chat comes back only when no resource is hiding it, and a resource's hide is removed when it stops.
isChatHidden
Check whether the chat is hidden (by any resource, the pause menu, or a screen fade).
local hidden = exports['wasabi_chat']:isChatHidden()
Returns: boolean
isChatOpen
Check whether the local player is typing in the chat.
local typing = exports['wasabi_chat']:isChatOpen()
Returns: boolean
clearChat
Clear the local player's chat feed. Wrist Link DMs stay. Use the server clearChat to also clear the server history.
exports['wasabi_chat']:clearChat()
Returns: boolean
Bubblesβ
showBubble
Show a bubble above a player's head that only the local player sees.
local success, reason = exports['wasabi_chat']:showBubble(serverId?, kind, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | No | Player the bubble shows above (must be nearby). nil for the local player. |
kind | string | Yes | 'me' ("* Name text"), 'do' ("text (( Name ))") or 'custom' (text only). |
text | string | Yes | Bubble text, up to bubbles.maxLength. |
opts | table | No | name (name shown) and duration (ms, 1000-30000). |
Returns: boolean, string? β true when shown, otherwise false and a reason (disabled, invalid_target, invalid_kind, invalid_text, invalid_options).
Wrist Linkβ
openWristLink
Open Wrist Link for the local player. In item mode the player needs the watch item.
local opened = exports['wasabi_chat']:openWristLink()
Returns: boolean β true if it opened.
closeWristLink
Close Wrist Link for the local player.
local closed = exports['wasabi_chat']:closeWristLink()
Returns: boolean β true if it was open.
Stock Chatβ
addMessage
Add a system message to the local player's chat, like the stock chat.
exports['chat']:addMessage({ color = { 255, 0, 0 }, args = { 'Server', 'Hello there!' } })
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string|table | Yes | A string, or { args, color?, multiline? }. The last args entry is the text; earlier entries become the sender name. color is { r, g, b }. |
Returns: boolean β false if the message is invalid.
addSuggestion
Add a command suggestion, like the stock chat.
exports['chat']:addSuggestion('/givecar', 'Give a car to a player', {
{ name = 'id', help = 'Player server id' },
{ name = 'model', help = 'Vehicle model' },
})
Returns: boolean β false if the suggestion is invalid.
Server Exportsβ
Messagesβ
sendMessage
Send a message to one player, everyone, or a list of players.
local success, reason = exports['wasabi_chat']:sendMessage(target, sender, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
target | number|table | Yes | A server ID, -1 for everyone, or a list of server IDs. |
sender | string|table | Yes | A sender ID from registerSender, or a table { name, color?, channel?, banner? }: name up to 48 bytes, color as #rrggbb, channel 'system', 'ooc' or 'local', banner (see opts). |
text | string | Yes | Message text, up to messageLength. Supports emojis and :name: Discord emojis. |
opts | table | No | color (#rrggbb), image (https link), banner (a .png file name from ui/build/assets/ or an https link) and channel. Links must use a host in customMessages.allowedImageDomains. |
Returns: boolean, string? β true when sent, otherwise false and a reason (no_recipients, disabled, invalid_target, invalid_text, invalid_options, invalid_color, invalid_sender, invalid_name, invalid_channel, unknown_sender, sender_disabled).
Script messages skip the word filter, mutes and slow mode. A bad image or banner is skipped with a console warning and the message still sends.
registerSender
Save a sender under an ID so you can reuse it. Senders are removed when the resource that added them stops. Server owners can override or disable any sender ID in customMessages.senders.
local success, reason = exports['wasabi_chat']:registerSender(id, sender)
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Letters, numbers, _ and -, up to 64 characters. Saved in lowercase. |
sender | table | Yes | { name, color?, channel?, banner? }, as in sendMessage. |
Returns: boolean, string? β true when saved, otherwise false and a reason (invalid_id, invalid_sender, invalid_name, invalid_color, invalid_channel).
removeSender
Remove a saved sender.
local removed = exports['wasabi_chat']:removeSender(id)
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The sender ID. |
Returns: boolean β true if the sender existed.
sendToJob
Send a message to every online player with one of the given jobs.
local success, reason = exports['wasabi_chat']:sendToJob(jobs, sender, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
jobs | string|table | Yes | One job name or a list of job names. |
sender | string|table | Yes | Same as sendMessage. |
text | string | Yes | Message text. |
opts | table | No | Same as sendMessage, plus onDuty (true = on-duty players only) and minGrade (lowest job grade). |
Returns: boolean, string? β true when sent, otherwise false and a reason (invalid_job, invalid_options, no_recipients, or any sendMessage reason).
Older ESX versions without
job.onDutycannot check duty, soonDutylets every job member through.
sendNearby
Send a message to players near a location or a player, in every routing bucket. It shows in the Local tab unless opts.channel is set.
local success, reason = exports['wasabi_chat']:sendNearby(coords, radius, sender, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
coords | vector3|table|number | Yes | A vector3, a { x, y, z } table, or a server ID (uses that player's position). |
radius | number | Yes | Distance in meters, 1-200. |
sender | string|table | Yes | Same as sendMessage. |
text | string | Yes | Message text. |
opts | table | No | Same as sendMessage. |
Returns: boolean, string? β true when sent, otherwise false and a reason (invalid_coords, invalid_radius, invalid_options, no_recipients, or any sendMessage reason).
sendAnnouncement
Send a job announcement card to everyone, the same as /jobannounce. It skips permission, duty and rate limit checks.
local success, reason = exports['wasabi_chat']:sendAnnouncement(job, status, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
job | string | Yes | A job from announcements.jobs. Its label and banner are used. |
status | string | Yes | An enabled status: 'open', 'closed', 'hiring', 'event' or 'general'. |
text | string | Yes | Announcement text. |
opts | table | No | label (replaces the job label, up to 64 bytes) and banner (replaces the job banner). |
Returns: boolean, string? β true when sent, otherwise false and a reason (invalid_job, unknown_job, invalid_status, invalid_text, invalid_options, invalid_label, no_recipients).
getDiscordEmoji
Get the raw form of an emoji from your Discord emoji pack. The name must match exactly, including capitals; the colons are optional.
local token = exports['wasabi_chat']:getDiscordEmoji(name)
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Emoji name, for example 'casino_chip'. |
Returns: string|nil β For example '<:casino_chip:123456789012345678>', or nil if it is not in the pack.
Wrist Linkβ
sendWristNotification
Show a notification on the player's Wrist Link watch, like the one for a new DM.
local success, reason = exports['wasabi_chat']:sendWristNotification(target, data)
| Parameter | Type | Required | Description |
|---|---|---|---|
target | number|table | Yes | A server ID, -1, or a list of server IDs. |
data | table | Yes | title (up to 64 bytes), text (up to 160 bytes) and sound (false = silent, default true). |
Returns: boolean, string? β true when at least one player got it, otherwise false and a reason (disabled, invalid_target, invalid_data, invalid_title, invalid_text, no_recipients).
Only players with a loaded character get it; in item mode, only players holding the watch item. Your own notify script receives it through the
wristLinklistener with kind'custom'.
sendSystemDM
Put a read-only message in the player's Wrist Link inbox, as a conversation with the sender. It is saved and counted like a normal DM (unread badge, notification).
local success, reason = exports['wasabi_chat']:sendSystemDM(target, sender, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
target | number|table | Yes | A server ID, -1, or a list of online server IDs. |
sender | string|table | Yes | Same as sendMessage. Its name is the contact name. Each sender ID (or table id, or name) gets one conversation. |
text | string | Yes | Message text. No images. |
opts | table | No | sound (false = silent). |
Returns: boolean, string? β true when at least one player got it, otherwise false and a reason (disabled, invalid_target, invalid_sender, unknown_sender, invalid_text, invalid_options, no_recipients, error_persistence).
hasWristLink
Check whether Wrist Link is on and the player has a loaded character (in item mode, also holding the watch item).
local hasWatch = exports['wasabi_chat']:hasWristLink(serverId)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | Yes | The player's server ID. |
Returns: boolean
getWristAccount
Get a player's Wrist Link account info (read-only). It never returns IDs, passwords, PINs or hashes.
local account = exports['wasabi_chat']:getWristAccount(serverId)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | Yes | The player's server ID. |
Returns: table|nil β { displayName, signedIn, handle?, viaPin? }, or nil if Wrist Link is off or no character is loaded. handle (account name) and viaPin (unlocked someone else's watch with its PIN) are only set in item mode.
Moderationβ
mutePlayer
Mute a player in chat, modes, /say, announcements, Wrist Link DMs and the built-in /me, /do, /roll and /try. Fires wasabi_chat:playerMuted.
local success, reason = exports['wasabi_chat']:mutePlayer(serverId, minutes?, reason?, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | Yes | Online player server ID. |
minutes | number | No | nil or 0 = until unmuted. Up to 525600. |
reason | string | No | Up to 128 bytes. |
opts | table | No | persist (save in the database, default mutes.persist), notify (tell the player, default false) and by (name in logs, default your resource name). |
Returns: boolean, string? β true when muted, otherwise false and a reason (invalid_target, invalid_minutes, invalid_reason, invalid_options).
unmutePlayer
Unmute an online player and delete the saved mute. Fires wasabi_chat:playerUnmuted.
local success, reason = exports['wasabi_chat']:unmutePlayer(serverId, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | Yes | Online player server ID. |
opts | table | No | notify and by, as in mutePlayer. |
Returns: boolean, string? β true when unmuted, otherwise false and a reason (invalid_target, not_muted).
isMuted
Check whether a player is muted.
local muted, secondsLeft, reason = exports['wasabi_chat']:isMuted(serverId)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | Yes | The player's server ID. |
Returns: boolean, number?, string? β Muted, seconds left (nil = until unmuted) and the reason.
setSlowMode
Set how many seconds each player must wait between messages in a channel. Not saved: the config value is used again after a restart.
local success, reason = exports['wasabi_chat']:setSlowMode(channel, seconds, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
channel | string | Yes | 'local', 'ooc', 'staff', 'groups', 'dm' or 'all'. |
seconds | number | Yes | 0-3600. 0 turns it off. |
opts | table | No | notify (true tells players in System). |
Returns: boolean, string? β true when set, otherwise false and a reason (invalid_channel, invalid_seconds, invalid_options).
getSlowMode
Get the slow mode seconds for a channel, or for every channel.
local seconds = exports['wasabi_chat']:getSlowMode(channel?)
| Parameter | Type | Required | Description |
|---|---|---|---|
channel | string | No | Channel name. Omit to get a table of every channel. |
Returns: number|table|nil β nil if the channel is unknown.
filterText
Run text through the word filter. Works even if the filter is turned off. Use it on player text your script passes along.
local text, matched = exports['wasabi_chat']:filterText(input)
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Text to check. |
Returns: string, boolean β The censored text, and true if anything matched.
addFilterWords
Add words to the word filter until the next restart. A word ending in * also matches longer words that start with it.
local added = exports['wasabi_chat']:addFilterWords(words)
| Parameter | Type | Required | Description |
|---|---|---|---|
words | string|table | Yes | One word or a list of words. |
Returns: number β How many words changed.
removeFilterWords
Remove words from the word filter (config words too) until the next restart.
local removed = exports['wasabi_chat']:removeFilterWords(words)
| Parameter | Type | Required | Description |
|---|---|---|---|
words | string|table | Yes | One word or a list of words. |
Returns: number β How many words changed.
Chatβ
showBubble
Show a bubble above a player's head for nearby players. It skips mute, rate limit, slow mode and word filter checks.
local success, reason = exports['wasabi_chat']:showBubble(serverId, kind, text, opts?)
| Parameter | Type | Required | Description |
|---|---|---|---|
serverId | number | Yes | Player the bubble shows above. |
kind | string | Yes | 'me', 'do' or 'custom'. |
text | string | Yes | Bubble text, up to bubbles.maxLength. |
opts | table | No | showInChat (also post in the Local tab), distance (1-100) and duration (ms, 1000-30000). |
Returns: boolean, string? β true when shown, otherwise false and a reason (disabled, invalid_target, invalid_kind, invalid_text, invalid_options).
clearChat
Clear the chat and the server history it is rebuilt from. Wrist Link DMs stay.
local success = exports['wasabi_chat']:clearChat(target?)
| Parameter | Type | Required | Description |
|---|---|---|---|
target | number|table | No | A server ID or a list of server IDs. Omit (or -1) for everyone. |
Returns: boolean, string? β true, or false, 'invalid_target'.
setChatHidden
Hide or show the chat for players, for example during a cutscene. Each resource has its own hide, removed when that resource stops.
local success, reason = exports['wasabi_chat']:setChatHidden(target, hidden)
| Parameter | Type | Required | Description |
|---|---|---|---|
target | number|table | Yes | A server ID, -1, or a list of server IDs. |
hidden | boolean | Yes | true to hide, false to remove your hide. |
Returns: boolean, string? β true, or false and a reason (invalid_value, invalid_target).
Stock Chatβ
addMessage
Add a system message for one player or everyone, like the stock chat.
exports['chat']:addMessage(target?, message)
| Parameter | Type | Required | Description |
|---|---|---|---|
target | number | No | A server ID or -1. Omit to send to everyone. |
message | string|table | Yes | A string, or { args, color?, multiline? } (see the client addMessage). |
Returns: boolean β true if delivered.
registerMessageHook
Run a function on every player chat message before it is sent, like the stock chat. Hooks are removed when your resource stops.
local hookId = exports['chat']:registerMessageHook(function(source, outMessage, hookRef)
if outMessage.args[#outMessage.args]:find('discord.gg') then
hookRef.cancel()
end
end)
hookRef function | Description |
|---|---|
cancel() | Drops the message silently. The sender gets no error. |
updateMessage({ args = { ... } }) | Replaces the text with the last args entry. |
setSeObject(ace) | Only players with this ace get the message. |
setRouting(target) | Only these server IDs get the message (-1 = no limit). |
Returns: number|false β A hook ID, or false if hook is not a function.
registerMode
Add a chat mode players can pick, like the stock chat. Its messages show displayName as the tag and use color. Modes are removed when your resource stops.
local success = exports['chat']:registerMode({ name = 'twt', displayName = 'Twitter', color = '#1da1f2', isGlobal = true, cb = function(source, outMessage, hookRef) end })
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Mode name, up to 64 characters, no spaces. |
displayName | string | Yes | Tag shown on the mode's messages, up to 64 characters. |
cb | function | Yes | Runs for each message, with the same hookRef as registerMessageHook. If it cancels or errors, the message is dropped silently. |
color | string | No | #rrggbb. Default #ffffff. |
isGlobal | boolean | No | true sends to OOC, otherwise Local. |
isChannel | boolean | No | Stock chat flag, passed to the client. |
seObject | string | No | Only players with this ace can use the mode. |
Returns: boolean β false if the mode is invalid.