DirkScripts Logo

Login With FiveM

Login

πŸ“š Library
β€Ί
Modules
β€Ί

addCommand

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.

lua
lib.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

lua
lib.addCommand(commandName, properties, cb)
ParameterTypeRequiredDescription
commandNamestring | string[]yesCommand name(s) to register
propertiestable | falseyesCommand properties, or false for no restrictions/params
cbfunctionyesHandler function(source, args, raw)

Properties

FieldTypeDescription
helpstringDescription shown in chat suggestions
restrictedstring | falseACE permission required (e.g. "group.admin")
paramstable[]Parameter definitions

Parameter Types

TypeDescription
numberParsed as a number
playerIdValidated server ID of an online player
stringSingle word string
longStringRest of the input as one string (must be last param)

Multiple Aliases

Pass a table to register the same handler under multiple command names:

lua
lib.addCommand({'tp', 'teleport'}, { ... }, function(source, args) end)

Copyright Β© 2026 DirkScripts.

Not affiliated with or endorsed by Rockstar North, Take-Two Interactive, or any other rights holders. FiveM is a copyright and registered trademark of Take-Two Interactive Software, Inc.
Our checkout system is provided by Tebex Limited, who manage payment processing, product delivery, and billing support. Prices shown in currencies other than GBP are approximate conversions updated daily. All purchases are processed in GBP, so the final amount charged may vary depending on your bank or payment provider’s exchange rate.