0r-chat registers exports and stays compatible with the default chat event names via provide 'chat'. Prefer exports from your own resources; use the chat:* events when you need stock-chat compatibility.
Message payload#
| Field | Type | Notes |
|---|---|---|
type | string | Must exist in messageTypes (falls back to defaultMessageType) |
author | string | Display name |
message | string | Body text (sanitized) |
args | table | Legacy: [author, message] or [message] — still accepted on server |
multiline | boolean | Optional |
tags | table | Optional author tags |
color | string | Optional color override |
senderId | number | Optional server id |
proximity | boolean | Mark as proximity-related when relevant |
imageUrl | string | Used for image messages from the UI / /img flow |
Client exports#
| Export | Signature | Purpose |
|---|---|---|
openChat | () | Open and focus chat |
closeChat | () | Close chat |
isChatOpen | () → boolean | Whether chat is focused |
clearChat | () | Clear local message list |
addMessage | (data) | Add a message on this client |
registerChatHook | (callback) → hook|false | Block open if callback returns false |
canOpenChat | () → boolean | Run all hooks; false if any blocks |
addSuggestion | (command, help, params?) | Register one suggestion |
addSuggestions | (suggestions[]) | Register many |
removeSuggestion | (command) | Remove a suggestion |
display3D | (playerId, data) | Show a local 3D bubble above a player |
Open / close example#
exports['0r-chat']:openChat()
if exports['0r-chat']:isChatOpen() then
exports['0r-chat']:closeChat()
end
Hook example#
Requires enableHooks = true in config. Return false to prevent opening.
local hook = exports['0r-chat']:registerChatHook(function()
if LocalPlayer.state.busy then
return false
end
end)
-- later
if hook then
hook:delete()
end
Suggestion example#
exports['0r-chat']:addSuggestion('/report', 'Report a player', {
{ name = 'id', help = 'Server ID' },
{ name = 'reason', help = 'Why you are reporting' },
})
Server exports#
| Export | Signature | Purpose |
|---|---|---|
addMessage | (targets?, data) | Send chat to targets; message table alone broadcasts |
display3D | (targets, sourceId, data) | Show a 3D bubble above sourceId for targets |
targets can be a player id, a list of ids, or -1 for everyone. If the first argument is already a message table (message or args), it broadcasts.
Broadcast example#
exports['0r-chat']:addMessage({
type = 'system',
author = 'SYSTEM',
message = 'Server restart in 5 minutes.',
})
Targeted example#
exports['0r-chat']:addMessage(source, {
type = 'pm',
author = 'Staff',
message = 'Please read the rules.',
})
3D example#
exports['0r-chat']:display3D(nil, source, {
text = 'looks around',
type = 'me',
})
Pass nil for targets to use nearby players when useServerProximity is on, or everyone otherwise. data supports text, optional type, author, and duration.
Compatibility events#
These mirror the default chat API so older scripts keep working:
| Event | Side | Role |
|---|---|---|
chat:addMessage | Client + server | Add / relay a message |
chat:addSuggestion | Client | Add one suggestion |
chat:addSuggestions | Client | Add many |
chat:removeSuggestion | Client | Remove one |
Resource-scoped events also cover addMessage, suggestions, proximity sends, dice/RPS, typing, display3D, and song preview. Prefer exports for new integrations.
Client listenables#
Other resources can listen for:
| Event | When |
|---|---|
0r-chat:client:chatOpened | Chat gained focus |
0r-chat:client:chatClosed | Chat lost focus |
0r-chat:client:messageAdded | A message was added to the local list |
0r-chat:client:messageSent | The local player sent a message |