Skip to Content
ResourcesChatExportsregisterMessageHook

This server export registers a function that runs on every outgoing chat message before it’s sent, letting you rewrite its contents, cancel it, change its ACE requirement, or change its routing. The hook function receives a hookRef with helpers to act on the message.

Export Name

registerMessageHook

Parameters

  • function hookFunction: function(source, outMessage, hookRef), called for each outgoing message

hookRef Functions

  • updateMessage(object messageObject): Replaces the message object with the one provided
  • cancel(): Cancels the message so it’s never sent
  • setSeObject(string seObject): Changes the message’s ACE requirement
  • setRouting(int|table player(s)): Changes who the message is routed to

Example

exports.chat:registerMessageHook(function(source, outMessage, hookRef) if string.find(string.lower(outMessage.args[2]), 'slugs') then local filtered = string.gsub(string.lower(outMessage.args[2]), 'slugs', 'snails') hookRef.updateMessage({ args = { outMessage.args[1], filtered } }) end end)