Skip to main content

Exports

Exports documented currently for Wasabi Chat (wasabi_chat).

Every export except openWristLink and closeWristLink is also available as exports['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?)
ParameterTypeRequiredDescription
senderstring|tableYesA sender ID from registerSender, or a table { name, color?, channel?, banner? }. See the server sendMessage.
textstringYesMessage text.
optstableNo{ 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)
ParameterTypeRequiredDescription
idstringYesLetters, numbers, _ and -, up to 64 characters.
sendertableYes{ 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)
ParameterTypeRequiredDescription
idstringYesThe 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)
ParameterTypeRequiredDescription
hiddenbooleanYestrue 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?)
ParameterTypeRequiredDescription
serverIdnumberNoPlayer the bubble shows above (must be nearby). nil for the local player.
kindstringYes'me' ("* Name text"), 'do' ("text (( Name ))") or 'custom' (text only).
textstringYesBubble text, up to bubbles.maxLength.
optstableNoname (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).

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!' } })
ParameterTypeRequiredDescription
messagestring|tableYesA 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?)
ParameterTypeRequiredDescription
targetnumber|tableYesA server ID, -1 for everyone, or a list of server IDs.
senderstring|tableYesA 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).
textstringYesMessage text, up to messageLength. Supports emojis and :name: Discord emojis.
optstableNocolor (#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)
ParameterTypeRequiredDescription
idstringYesLetters, numbers, _ and -, up to 64 characters. Saved in lowercase.
sendertableYes{ 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)
ParameterTypeRequiredDescription
idstringYesThe 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?)
ParameterTypeRequiredDescription
jobsstring|tableYesOne job name or a list of job names.
senderstring|tableYesSame as sendMessage.
textstringYesMessage text.
optstableNoSame 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.onDuty cannot check duty, so onDuty lets 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?)
ParameterTypeRequiredDescription
coordsvector3|table|numberYesA vector3, a { x, y, z } table, or a server ID (uses that player's position).
radiusnumberYesDistance in meters, 1-200.
senderstring|tableYesSame as sendMessage.
textstringYesMessage text.
optstableNoSame 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?)
ParameterTypeRequiredDescription
jobstringYesA job from announcements.jobs. Its label and banner are used.
statusstringYesAn enabled status: 'open', 'closed', 'hiring', 'event' or 'general'.
textstringYesAnnouncement text.
optstableNolabel (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)
ParameterTypeRequiredDescription
namestringYesEmoji name, for example 'casino_chip'.

Returns: string|nil β€” For example '<:casino_chip:123456789012345678>', or nil if it is not in the pack.

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)
ParameterTypeRequiredDescription
targetnumber|tableYesA server ID, -1, or a list of server IDs.
datatableYestitle (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 wristLink listener 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?)
ParameterTypeRequiredDescription
targetnumber|tableYesA server ID, -1, or a list of online server IDs.
senderstring|tableYesSame as sendMessage. Its name is the contact name. Each sender ID (or table id, or name) gets one conversation.
textstringYesMessage text. No images.
optstableNosound (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)
ParameterTypeRequiredDescription
serverIdnumberYesThe 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)
ParameterTypeRequiredDescription
serverIdnumberYesThe 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?)
ParameterTypeRequiredDescription
serverIdnumberYesOnline player server ID.
minutesnumberNonil or 0 = until unmuted. Up to 525600.
reasonstringNoUp to 128 bytes.
optstableNopersist (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?)
ParameterTypeRequiredDescription
serverIdnumberYesOnline player server ID.
optstableNonotify 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)
ParameterTypeRequiredDescription
serverIdnumberYesThe 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?)
ParameterTypeRequiredDescription
channelstringYes'local', 'ooc', 'staff', 'groups', 'dm' or 'all'.
secondsnumberYes0-3600. 0 turns it off.
optstableNonotify (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?)
ParameterTypeRequiredDescription
channelstringNoChannel 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)
ParameterTypeRequiredDescription
inputstringYesText 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)
ParameterTypeRequiredDescription
wordsstring|tableYesOne 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)
ParameterTypeRequiredDescription
wordsstring|tableYesOne 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?)
ParameterTypeRequiredDescription
serverIdnumberYesPlayer the bubble shows above.
kindstringYes'me', 'do' or 'custom'.
textstringYesBubble text, up to bubbles.maxLength.
optstableNoshowInChat (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?)
ParameterTypeRequiredDescription
targetnumber|tableNoA 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)
ParameterTypeRequiredDescription
targetnumber|tableYesA server ID, -1, or a list of server IDs.
hiddenbooleanYestrue 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)
ParameterTypeRequiredDescription
targetnumberNoA server ID or -1. Omit to send to everyone.
messagestring|tableYesA 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 functionDescription
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 })
FieldTypeRequiredDescription
namestringYesMode name, up to 64 characters, no spaces.
displayNamestringYesTag shown on the mode's messages, up to 64 characters.
cbfunctionYesRuns for each message, with the same hookRef as registerMessageHook. If it cancels or errors, the message is dropped silently.
colorstringNo#rrggbb. Default #ffffff.
isGlobalbooleanNotrue sends to OOC, otherwise Local.
isChannelbooleanNoStock chat flag, passed to the client.
seObjectstringNoOnly players with this ace can use the mode.

Returns: boolean β€” false if the mode is invalid.