Skip to main content

Command

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

Registers a command using ESX functions.

Example

ESX.Command('heal', 'admin', function(xPlayer, args, show_error)
xPlayer.heal()
end, false)
ESX.Command('car', 'admin', function(xPlayer, args, show_error)
if not args.model then args.model = "t20" end
xPlayer.emit("esx:createVehicle",args.model)
end, false, { help = 'Spawn a vehicle', validate = false, arguments = {{name = 'model', 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