Skip to content

ax.chat

Source: gamemode/framework/libraries/sh_chat.lua

Chat system for registering chat types with commands, permissions, and custom formatting.

Documented functions: 12

Functions


ax.chat:Add(key, def)

Register a chat type definition. Adds a chat mode to the registry and, on the client, automatically registers matching slash commands that route through the chat system. Default CanHear and CanSay callbacks are generated when omitted.

Realm: shared

Parameters

Name Type Description
key string Unique chat type identifier (for example "ic" or "y")
def table Chat definition (name, prefix, hearDistance, formatting callbacks, etc.)

Usage

ax.chat:Add("ic", { name = "In Character", prefix = {"/me"} })
ax.chat:Add("y", { name = "Yell", hearDistance = 1024, noSpaceAfter = false })

ax.chat:ApplyShortcuts(text)

Apply chat shortcuts to text

Realm: shared

Parameters

Name Type Description
text string The text to process

Returns

  • string: The text with shortcuts replaced

ax.chat:BuildFontName(baseFont, styles)

Build font name from active styles

Realm: shared

Parameters

Name Type Description
baseFont string The base font name
styles table Table of active styles (bold, italic)

Returns

  • string: The complete font name

ax.chat:CapitalizeSentences(text)

Capitalize the first letter of sentences

Realm: shared

Parameters

Name Type Description
text string The text to capitalize

Returns

  • string: The capitalized text

ax.chat:DetectCapitalization(text)

Detect capitalization style of text

Realm: shared

Parameters

Name Type Description
text string The text to analyze

Returns

  • string: "upper", "lower", or "mixed"

ax.chat:FixPronounI(text)

Fix pronoun "I" capitalization

Realm: shared

Parameters

Name Type Description
text string The text to fix

Returns

  • string: The fixed text

ax.chat:Format(message, options)

Format a chat message with text processing and optional markdown

Realm: shared

Parameters

Name Type Description
message string The message to format
options table Options table (baseFont, markdown)

Returns

  • string: The formatted message

Usage

local text = ax.chat:Format("hello there")
local rich = ax.chat:Format("**hello**", { baseFont = "ax.small.shadow", markdown = true })

ax.chat:FormatWithMarkdown(message, baseFont)

Format a message with markdown support enabled. Convenience wrapper around ax.chat:Format that forces markdown parsing.

Realm: shared

Parameters

Name Type Description
message string The message to format

Returns

  • string: The formatted message with markdown tags applied

Usage

local rich = ax.chat:FormatWithMarkdown("**Hello** there", "ax.small.shadow")

ax.chat:NormalizeSpacing(text)

Normalize spacing in text

Realm: shared

Parameters

Name Type Description
text string The text to normalize

Returns

  • string: The normalized text

ax.chat:Parse(message)

Identifies which chat mode should be used based on text input Credits to helix for the logic

Realm: shared

Parameters

Name Type Description
message string The input message

Returns

  • string: chatType The identified chat type
  • string: message The processed after the chat type prefix is removed

Usage

local chatType, text = ax.chat:Parse("/y hello there")

ax.chat:ParseMarkdown(text, baseFont, styles)

Parse Discord-style markdown into font tags Supports: italic, bold, bold+italic

Realm: shared

Parameters

Name Type Description
text string The text to parse
baseFont string The base font name (default: "ax.small")
styles table Active styles being applied

Returns

  • string: The formatted text with font tags

ax.chat:Send(speaker, chatType, text, data, receivers)

Send a chat message to eligible receivers. Validates the chat class, runs CanSay/CanHear, applies hooks, and networks the final payload to recipients.

Realm: server

Parameters

Name Type Description
speaker Player\|Entity Message sender
chatType string Registered chat type key
text string Raw message text

Returns

  • string|nil: text Final processed text when sent successfully

Usage

ax.chat:Send(client, "ic", "hello", {})