Aliases & Prefixes
Default Prefixes
Commands use configurable global prefixes:
- Chat prefix:
"!"(default) — e.g.,!kick - Console prefix:
"lyn "(default, yes with a space) — e.g.,lyn kick
These are configured via command_chat_prefix and command_console_prefix in Lyn config.
Simple Aliases
Add multiple names for a command:
Command("teleport")
:Aliases("tp", "goto", "warp")
:Execute(function(caller, targets, destination)
-- ...
end)
:Add()
All aliases inherit the command's chat/console prefixes:
- Chat:
!teleport,!tp,!goto,!warp - Console:
lyn teleport,lyn tp,lyn goto,lyn warp
Custom Alias Prefixes
Override prefixes for specific aliases using :CustomAlias():
Command("adminsay")
:CustomAlias("@", { chat_prefix = "", sticky = true })
:Param("string", { hint = "message" })
:GetRestArgs()
:Execute(function(caller, message)
-- ...
end)
:Add()
This creates:
!adminsay message— standard chat command@message— no prefix, sticky matching
CustomAlias Options
| Option | Type | Description |
|---|---|---|
chat_prefix | string | Override chat prefix for this alias |
console_prefix | string | Override console prefix for this alias |
sticky | boolean | Match without requiring space after alias |
Sticky Aliases
By default, aliases only match when followed by a space or end of input. With sticky = true, the alias matches even when text follows immediately.
-- Input: "@hello world"
-- sticky = false (default)
-- "@" does NOT match because "h" follows directly (no space)
-- User must type: "@ hello world"
-- sticky = true
-- "@" matches immediately
-- "hello world" is passed as arguments
Essential for symbol-based shortcuts like @, /w, etc.
Per-Command Prefix Override
Override prefixes for the entire command (all aliases):
Command("rcon")
:ChatPrefix("/") -- Chat: /rcon
:ConsolePrefix("sv_") -- Console: sv_rcon
:Execute(function(caller, cmd)
-- ...
end)
:Add()
Mixed Example
Command("pm")
:Aliases("msg", "whisper")
:CustomAlias("/w", { chat_prefix = "", sticky = true })
:CustomAlias("tell", { console_prefix = "" }) -- console: tell (no prefix)
:Permission("pm")
:Param("player", { single_target = true, cant_target_self = true })
:Param("string", { hint = "message" })
:GetRestArgs()
:Execute(function(caller, targets, message)
local target = targets[1]
Lyn.Player.Chat.Send(caller, "To " .. target:Name() .. ": " .. message)
Lyn.Player.Chat.Send(target, "From " .. caller:Name() .. ": " .. message)
end)
:Add()
Results in:
- Chat:
!pm,!msg,!whisper,/wplayer message - Console:
lyn pm,lyn msg,lyn whisper,tell
How Matching Works
Commands are stored in a prefix trie for efficient lookup:
- User types
!kick player - System searches chat prefix trie for longest match starting with
!kick - Finds
!kick, extracts remaining text as arguments - For sticky aliases, no space boundary required after the match
warning
Alias conflicts throw errors at registration. Ensure aliases (with their prefixes) are unique across all commands.