FiveM scripts · Cortex Chat

Cortex Chat commands, settings, and developer API

Every command and keybind, the Chat options in Cortex Settings, and the exports and events other resources can use.

8 sections · 5 min read

Type commands with or without a slash

Input starting with / runs a command. Input whose first word matches a registered command also runs it, so typing help works. Anything else is sent as a chat message.

A server can set Config.Chat.ForceCommand to treat all input as commands. Players can do the same for themselves with Command Line Mode.

Commands

Commands for /me, /gme, /ooc, /rolldice, and /dv exist only when enabled in config.lua. Chat, /me, /gme, /ooc, and /rolldice share the message cooldown and flood lock.

CommandWho can use itWhat it does
/helpEveryoneShows how command detection works.
/clearEveryoneClears your own chat history.
/me actionEveryoneShows your action as italic 3D text above your head to nearby players.
/gme actionEveryonePosts a global italic action line to all players.
/ooc messageEveryoneSends an out-of-character message, globally or to nearby players depending on Config.Ooc.Range.
/rolldice rangeEveryoneRolls a number shown as 3D text above your head. /rolldice 1-10 rolls 1 to 10. /rolldice 100 rolls 1 to 100.
/dvPlayers with a /dv grantDeletes the vehicle you are driving, or the nearest vehicle within range.
/togglechatEveryoneCycles chat visibility: Active, Hidden, Always Show. Bound to L by default.
/eschat_resetfocusEveryoneReleases your controls if chat keeps focus.
/cortexsettingsEveryoneOpens Cortex Settings, provided by Cortex Lib. Choose the Chat tab.
cortexchat_dvcheck server-idServer console onlyPrints whether a player can use /dv and why.

How /dv decides

The server checks permission, then the vehicle. It must be networked, within Config.Dv.Range (6 units by default), and in your routing bucket. If you are inside it, you must be the driver. Another driver or any other player inside blocks deletion.

One request is allowed every 1,500 ms by default. The success message appears only after the server confirms the vehicle is gone.

Keybinds

T and L are FiveM key mappings named Open Chat and Toggle Chat Visibility. Players can rebind them in FiveM's key binding settings.

KeyAction
TOpen chat
LCycle chat visibility
EnterSend
EscapeClose chat
TabComplete the selected suggestion
Arrow Up / Arrow DownMove through suggestions, or browse your sent messages when no suggestions are shown
Page Up / Page DownScroll chat history

Player settings

Open /cortexsettings and choose Chat. Changes apply immediately and are saved locally through Cortex Lib.

SettingDefaultOptions
VisibilityActiveActive fades messages after Fade Time. Always Show keeps them. Hidden turns chat off. L cycles the same setting.
PositionTop Left (Top Right when Config.Position.Side is 'right')Top Left, Top Center, Top Right, Bottom Left, Bottom Right.
SizeDefaultSmall, Default, Large, Extra large. Scales text, spacing, and width together.
Background Opacity60%0 to 100% in steps of 5. The typing field stays solid.
FontCortex (Arial)Cortex (Arial), Segoe UI, Bahnschrift, Cortex Condensed, Verdana, Tahoma, Trebuchet MS, Georgia (serif), Consolas (monospace).
AccentFollow Cortex accentMint, Sky, Sage, Amber, Coral, Rose, Lavender, or Paper.
Custom AccentEmptyA #RGB or #RRGGBB color. Overrides Accent when valid.
Accent Player NamesOffPlayer names and ^3 text use the accent instead of amber.
Fade Time8 s1 to 30 seconds. Announcements stay twice as long.
History Length5010 to 200 messages, in steps of 5.
Command Line ModeOffTreats everything you type as a command.

Exports for developers

Server exports need a valid player ID, or -1 for everyone. An invalid target is rejected instead of broadcast. The resource sending the message decides who may send what.

Server or client Lua
-- Server: one player
exports['cortex-chat']:addMessage(source, { args = { 'Dispatch', 'Unit assigned.' }, type = 'info' })

-- Server: everyone
exports['cortex-chat']:addMessage(-1, { args = { 'Server restarting in 10 minutes.' }, type = 'announcement' })

-- Client: colored line with an author
exports['cortex-chat']:addMessage({ color = {255, 0, 0}, args = { 'Error', 'Something went wrong' } })

SideExportUse
ClientaddMessage(data)Add a message locally.
ClientregisterSuggestion(name, help, params)Add an autocomplete suggestion. help and params are optional.
Clientopen() / close()Open or close the chat input.
ClientisOpen()Returns true while the input is open.
ClientgetSettingsDefinition()Returns the Chat settings definition used by Cortex Lib.
ServeraddMessage(target, data)Send a message to one player, or -1 for all.
ServerclearChat(target)Clear chat for one player, or -1 for all.
ServerregisterSuggestion(name, help, params)Send a suggestion to all players.

Message types

Set type on a message to change how it looks. Aliases: inform and notice become info, warn becomes warning, announce and broadcast become announcement.

color applies to plain and channel lines. Its hue is kept and softened to fit the palette. Color codes ^0 to ^9 work in text. template takes {0}, {1} placeholders and renders as plain text; HTML is shown as text and never runs.

TypeLook
NonePlayer chat: name and plain text.
ooc, me, gmeChannel line with an OOC, ME, or GLOBAL label. me and gme are italic.
system, infoSteel blue notice card.
successSage notice card.
warning, spam-localAmber-orange notice card.
errorCoral notice card.
announcementAccent card with larger text that stays twice as long.

Compatible events

The client listens for these events, so many existing resources keep working. Stock chat templates, chat modes, registerMessageHook, and exports['chat'] are not supported.

Player-to-server events such as cortex-chat:serverMessage are internal and rate limited. Use the server exports for trusted server messages.

EventPurpose
chat:addMessageStandard Cfx chat message.
chatMessageLegacy message with author, color, text.
chat:addSuggestionAdd one suggestion.
chat:addSuggestionsAdd several suggestions.
chat:removeSuggestionRemove a suggestion.
chat:clearClear local chat history.
cortex-chat:addMessageNative Cortex Chat message.
cortex-chat:clearClear the chat window.