nut.chat
Extended Chatbox Module.
The NutScript chatbox is a custom implementation, rather than using the default GMOD chatbox. This allows the chatbox to contain additional features, such as multiple different chat types and categories.
Functions
nut.chat.timestamp (ooc)
nut.chat.timestamp
Returns a formatted timestamp for chat messages.
Parameters:
boolean ooc Whether timestamp is for OOC chatReturns:
string The formatted timestampnut.chat.register (chatType, data)
nut.chat.register
Registers a new chat type with the information provided.
Parameters:
string chatType Unique identifier for the chat typetable data Configuration table for the chat type
See also:
Usage:
nut.chat.parse (client, message, noSend)
nut.chat.parse
Parses a chat message to determine its type and processes it.
Parameters:
Client client The player sending the messagestring message The chat message content
boolean
noSend
optional. default
: false
Whether to skip sending the message
Returns:
string The chat type usedstring The processed message
bool Whether the sender is anonymous
nut.chat.send (speaker, chatType, text, anonymous, receivers)
nut.chat.send
Send a chat message using the specified chat type.
Parameters:
Client speaker The player sending the messagestring chatType The type of chat message
string text The message content
boolean
anonymous
optional. default
: false
Whether sender should be anonymous
table
receivers
optional
Optional list of specific receivers
Tables
ChatType
ChatType
Configuration table for registering a new chat type
Fields:
vararg radius Maximum hearing distance. If number, fixed distance from speaker in HU. Otherwise Function()vararg prefix Command prefix(es) (string or table of strings)
string format The message format string (uses %s for name/text)
Color color Default color for this chat type
string font Custom font to use
string filter The chat filter category ("ic", "ooc", etc.)
boolean deadCanChat Whether dead players can use this chat
boolean noSpaceAfter If true, no space required after prefix (For instance with // "ooc", //text would be valid without the need to separate // from the message with a space)
function onCanSay Function(speaker, text) - checks if player can speak
function onCanHear Function(speaker, listener) - checks if listener can hear
function onChatAdd Function(speaker, text, anonymous) - custom display handler
function onGetColor Function(speaker, text) - dynamic color handler