DirkScripts
Docs
addCommand
βΉοΈ Server Module - This can only be used on the server
#lib.addCommand
Register a chat command with automatic parameter parsing, type validation, and ACE permission restrictions.
lualib.addCommand('givemoney', { help = 'Give money to a player', restricted = 'group.admin', params = { { name = 'target', type = 'playerId', help = 'Target player' }, { name = 'amount', type = 'number', help = 'Amount to give' }, { name = 'reason', type = 'longString', help = 'Reason', optional = true }, }, }, function(source, args, raw) lib.player.addMoney(args.target, 'cash', args.amount, args.reason or 'admin') end)
#Signature
lualib.addCommand(commandName, properties, cb)
| Parameter | Type | Required | Description |
|---|---|---|---|
| commandName | string | string[] | yes | Command name(s) to register |
| properties | table | false | yes | Command properties, or false for no restrictions/params |
| cb | function | yes | Handler function(source, args, raw) |
#Properties
| Field | Type | Description |
|---|---|---|
help | string | Description shown in chat suggestions |
restricted | string | false | ACE permission required (e.g. "group.admin") |
params | table[] | Parameter definitions |
#Parameter Types
| Type | Description |
|---|---|
number | Parsed as a number |
playerId | Validated server ID of an online player |
string | Single word string |
longString | Rest of the input as one string (must be last param) |
#Multiple Aliases
Pass a table to register the same handler under multiple command names:
lualib.addCommand({'tp', 'teleport'}, { ... }, function(source, args) end)
