Chat¶
Chat helpers for registering chat classes, parsing player messages, formatting timestamps, and sending chat messages to eligible recipients.
Overview
lia.chat.timestamp(ooc)View Source
Purpose
Builds the optional timestamp prefix used in chat output.
Realm
Shared
Parameters
boolean ooc optional Whether the timestamp is being formatted for out-of-character chat spacing.
Returns
string The formatted timestamp when chat timestamps are enabled, otherwise an empty string.
Example Usage
chat.AddText(lia.chat.timestamp(false), Color(255, 255, 255), "Message")
lia.chat.register(chatType, data)View Source
Purpose
Registers a chat class and prepares its defaults, prefixes, callbacks, command aliases, and metadata.
Realm
Shared
Parameters
string chatType Unique identifier for the chat class.
table data Chat class data, including optional arguments, prefix, desc, radius, onCanHear, onCanSay, color, format, onChatAdd, filter, noSpaceAfter, and deadCanChat fields.
Returns
Example Usage
lia.chat.register("radio", {
prefix = "/r",
radius = 1000,
format = "chatRadio"
})
lia.chat.parse(client, message, noSend)View Source
Purpose
Parses raw chat text, detects a matching chat class prefix, runs chat parsing hooks, and optionally sends the message on the server.
Realm
Shared
Parameters
Player client The player whose message is being parsed.
string message Raw message text entered by the player.
boolean noSend optional If true, parsing returns the resolved values without sending the message.
Returns
string|nil, string|nil, boolean|nil The resolved chat type, message text, and anonymous state. Returns nil when the message is empty or whitespace-only.
Example Usage
local chatType, text, anonymous = lia.chat.parse(client, "/ooc Hello", true)
lia.chat.send(speaker, chatType, text, anonymous, receivers)View Source
Purpose
Sends a chat message from a speaker to valid recipients for the chosen chat class.
Realm
Server
Parameters
Player speaker The player sending the message.
string chatType The registered chat class identifier to send through.
string text The message text to send.
boolean anonymous optional Whether the message should be treated as anonymous.
table|Player receivers optional Optional recipient or recipient list. When omitted, recipients are resolved from the chat class hearing rules.
Returns
Example Usage
lia.chat.send(client, "ic", "Hello there.")
Hooks
Library-specific hooks documented for this library.
ChatParsed(client, chatType, message, anonymous)View Source
Purpose
Allows plugins or modules to adjust a parsed chat message before server dispatch occurs.
Realm
Shared
Parameters
Player client The player whose message was parsed.
string chatType The detected chat class.
string message The parsed message text after prefix handling.
boolean anonymous Whether the message is currently marked as anonymous.
Returns
string|nil, string|nil, boolean|nil Return a new chat type, message, or anonymous state to override the parsed values. Return nil for any value that should remain unchanged.
GetDisplayedName(speaker, chatType)View Source
Purpose
Allows plugins or modules to override the display name used by the default chat output handler.
Realm
Client
Parameters
Player speaker The player whose display name is being requested.
string chatType The chat class currently being displayed.
Returns
string|nil Return a string to use it as the displayed speaker name. Return nil to use the normal player name or console fallback.
OnOOCMessageSent(client, message)View Source
PlayerMessageSend(speaker, chatType, message, anonymous, receivers)View Source
Purpose
Allows plugins or modules to modify chat message text before it is sent.
Realm
Server
Parameters
Player speaker The player sending the message.
string chatType The chat class being sent.
string message The message text being processed.
boolean anonymous Whether the message is being sent anonymously.
table receivers optional The resolved recipient list when available.
Returns
string|nil Return a string to replace the outgoing message text. Return nil to keep the existing text.