Skip to Content
ResourcesChatchat resource

About

The chat resource renders FiveM’s built-in NUI chat box and exposes events and exports for sending messages, registering command suggestions, defining reusable HTML templates, and hooking outgoing messages. It is included and maintained at the cfx-server-data  repository.

Exports

Client

  • addMessage - Adds a message to the local player’s chat
  • addSuggestion - Adds a command suggestion to the local player’s chat

Server

  • addMessage - Sends a message to a target player’s chat
  • registerMessageHook - Registers a hook that can modify or cancel outgoing messages before they’re sent
  • registerMode - Registers a custom chat mode

Events

Client

  • chat:addMessage - Sends a chat message to the local client
  • chat:addSuggestion - Adds a single command suggestion
  • chat:addSuggestions - Adds multiple command suggestions in one call
  • chat:removeSuggestion - Removes a previously added command suggestion
  • chat:addTemplate - Registers a reusable HTML message template
  • chat:clear - Clears the chat history
  • chatMessage - Deprecated client-side; use chat:addMessage instead

Server

  • chatMessage - Fires when a player sends a chat message, letting the server read, log, or reply to it