OrigenNetwork
Docs

Exports · origen_chat

origen_chat is fully compatible with the standard FiveM chat export API. All exports work both via exports['origen_chat'] and via the legacy __cfx_export_chat_* event system (which means resources that already use exports['chat'] will continue to work without changes).


Server-side exports

addMessage(target, message)

Send a message to a player (or all players if target = -1).

lua
exports['origen_chat']:addMessage(-1, {
    color     = { 255, 0, 0 },
    multiline = true,
    args      = { 'Server', 'Hello everyone!' },
})
 
-- Send to a specific player
exports['origen_chat']:addMessage(source, {
    args = { 'A message just for you' }
})

registerMessageHook(hook)

Register a hook that intercepts every chat message before it is sent. The hook receives the message data and can modify or cancel it.

lua
exports['origen_chat']:registerMessageHook(function(source, outgoing, cancel)
    -- outgoing: the message object
    -- cancel(): call to prevent the message from being sent
    if string.find(outgoing.args[1], 'badword') then
        cancel()
    end
end)

registerCommand(commands, handler, properties)

Register a server-side command that shows up in chat autocomplete.

lua
exports['origen_chat']:registerCommand('mycommand', function(source, args, rawCommand)
    print('Command used by', source)
end, {
    help   = 'My custom command',
    params = {
        { name = 'target', help = 'Player ID' }
    }
})

resetChat(target)

Clear the chat history for a player (or all players if target = -1).

lua
exports['origen_chat']:resetChat(-1)

Client-side exports

addMessage(message)

Display a message in the local player's chat.

lua
exports['origen_chat']:addMessage({
    color     = { 255, 255, 0 },
    multiline = true,
    args      = { 'System', 'You have received a reward!' },
})

addSuggestion(name, help, params)

Add a command autocomplete suggestion to the chat input.

lua
exports['origen_chat']:addSuggestion('/mycommand', 'Does something useful', {
    { name = 'target', help = 'Player ID' }
})

removeSuggestion(name)

Remove a command autocomplete suggestion.

lua
exports['origen_chat']:removeSuggestion('/mycommand')

clearChat()

Clear all messages from the local player's chat.

lua
exports['origen_chat']:clearChat()