Chatbox
Comprehensive chat system management with message routing and formatting for the Lilia framework.
Overview
lia.chat.timestamp(ooc)
Purpose
Prepend a timestamp to chat messages based on option settings.
When Called
During chat display formatting (client) to show the time.
Parameters
boolean ooc Whether the chat is OOC (affects spacing).
Returns
string Timestamp text or empty string.
Example Usage
chat.AddText(lia.chat.timestamp(false), Color(255,255,255), message)
lia.chat.register(chatType, data)
Purpose
Register a chat class (IC/OOC/whisper/custom) with prefixes and rules.
When Called
On initialization to add new chat types and bind aliases/commands.
Parameters
string chatType
table data Fields: prefix, radius/onCanHear, onCanSay, format, color, arguments, etc.
Example Usage
lia.chat.register("yell", {
prefix = {"/y", "/yell"},
radius = 600,
format = "chatYellFormat",
arguments = {{name = "message", type = "string"}},
onChatAdd = function(speaker, text) chat.AddText(Color(255,200,120), "[Y] ", speaker:Name(), ": ", text) end
})
lia.chat.parse(client, message, noSend)
Purpose
Parse a raw chat message to determine chat type, strip prefixes, and send.
When Called
On client (local send) and server (routing) before dispatching chat.
Parameters
Player client
string message
boolean noSend optional If true, do not forward to recipients (client-side parsing only).
Returns
string, string, boolean chatType, message, anonymous
Example Usage
-- client
lia.chat.parse(LocalPlayer(), "/y Hello there!")
-- server hook
hook.Add("PlayerSay", "LiliaChatParse", function(ply, txt)
if lia.chat.parse(ply, txt) then return "" end
end)
lia.chat.send(speaker, chatType, text, anonymous, receivers)
Purpose
Send a chat message to eligible listeners, honoring canHear/canSay rules.
When Called
Server-side after parsing chat or programmatic chat generation.
Parameters
Player speaker
string chatType
string text
boolean anonymous
table receivers optional Optional explicit receiver list.
Example Usage
lia.chat.send(ply, "ic", "Hello world", false)