ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
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

Managing jobs on your server?

Viper Multi-Job lets players hold several jobs and switch between them with grade, salary and duty handled — QBCore, QBox and ESX, validated server-side.

See Viper Multi-Job →