QBCoreserver
QBCore.Commands.Add
QBCore server documentation with a FiveM Lua example.
Summary
Registers a command with built-in permission levels in QBCore. Cleaner than raw RegisterCommand for admin/job commands.
Returns
void
Parameters
namestringCommand name.helpstringHelp text.argumentstableArgument definitions.argsRequiredbooleanWhether args are required.callbackfunctionfunction(source, args).permissionstringPermission level (e.g. 'admin').Example
QBCore.Commands.Add('heal', 'Heal a player', {{name='id', help='player id'}}, false, function(source, args)
-- ...
end, 'admin')Common pitfalls
- Set the permission level to gate admin commands.
- Define arguments so the auto-help works.
Related functions
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →