Skip to main content

Command

ESX.RegisterCommand(name, Permissions, cb, allowConsole,suggestion)

Registers A command using ESX functions.

Example

ESX.RegisterCommand({'clear', 'cls'}, 'user', function(xPlayer, args, showError)
xPlayer.triggerEvent('chat:clear')
end, false, {help = _U('command_clear')})
``

```lua
ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, showError)
if not args.radius then args.radius = 4 end
xPlayer.triggerEvent('esx:deleteVehicle', args.radius)
end, false, {help = _U('command_cardel'), arguments = {name = 'radius', help = _U('command_cardel_radius'), type = 'any'}})

Function Arguments

ArgumentData TypeOptionalDefault ValueExplanation
namestringNo-Name of Command
PermissionsstringNo-Minimum Permission Group
cbFunctionNoxPlayer, args, showErrorFunction to run
AllowConsoleboolNo-Can Be ran from console
suggestiontableYes-Chat Suggestion
argstableYes-Command Arguments

Command Argument Types

TypeExplanation
numberRequires a Integer Value
playerRequires A playerID, returns player object
stringString Input
itemChecks if input is a valid item
weaponChecks if input is a Weapon
anyAny Input allowed