Chat
Chat is a global utility class that connects Lua scripts to the in-game chat system.
It supports registering custom slash commands, adding chat messages locally, broadcasting announcements, and sending messages to specific players.
Commands registered through Chat.RegisterCommand(...) also become usable via the console
Tip
Chat is a static module — you don’t instantiate it. Use Chat.RegisterCommand(...), Chat.AddMessage(...), etc.
Examples#
-- sends a chat message to everyone
Chat.Broadcast('Welcome to the server!')
-- sends a message to a specific player (server only)
Chat.SendMessage('You just got your paycheck!', player)
-- registers a command
Chat.RegisterCommand('ping', {}, 'Pong', function(args)
Chat.AddMessage('Pong!')
end)
-- sends a chat message locally (client only)
Chat.AddMessage('You just got your paycheck!')
Functions#
RegisterCommand#
Registers a new custom chat command (e.g. /noclip)
Chat.RegisterCommand('noclip', {}, 'Toggles noclip mode', function(args)
print('Noclip toggled!')
end)
AddMessage#
Adds a local message to the player's chat feed
Chat.AddMessage('Welcome to the server!')
Broadcast#
Sends a global announcement to all players
Chat.Broadcast('The server will restart in 5 minutes')
SendMessage#
Sends a private message to a specific player controller
Chat.SendMessage('Hello, Player!', TargetPlayer)
Clear#
Clears the chat UI
Chat.Clear()
SetVisibility#
Shows or hides the chat UI widget
Chat.SetVisibility(false)
IsReady#
Returns true if the chat widget is currently bound and ready
if Chat.IsReady() then
Chat.AddMessage('Chat system ready.')
end
GetWidget#
Returns the current chat UI widget instance
local ui = Chat.GetWidget()
Text Formatting#
| Preview | Tag to type | Purpose |
|---|---|---|
| Cyan text | <cyan> |
Cyan foreground |
| Green text | <green> |
Green foreground |
| Blue text | <blue> |
Blue foreground |
| Purple text | <purple> |
Purple foreground |
| Marengo text | <marengo> |
Marengo/grey-blue |
| Yellow text | <yellow> |
Yellow foreground |
| Orange text | <orange> |
Orange foreground |
| Red text | <red> |
Red foreground |
| Grey text | <grey> |
Grey foreground |
| Bold text | <bold> |
Bold weight |
| Italic text | <italic> |
Italic style |
Info
Always remember to close the tag using </>
Quick example#
Chat.Broadcast('<cyan>Hello</> <bold>world!</>')
Warning
It is NOT possible to combine two or more styles together /(eg.: Bold + Red/).