diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index dc4a8fe6..0d5b7cf2 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -146,6 +146,14 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion) end end end + + if v.isValid and not error then + local candidate = newArgs[v.name] + local ok, res = pcall(v.isValid, candidate) + if not ok or res ~= true then + error = v.error or TranslateCap("commanderror_argumentmismatch_" .. (v.name or tostring(k)), k) + end + end --backwards compatibility if v.validate ~= nil and not v.validate then diff --git a/[core]/es_extended/server/modules/commands.lua b/[core]/es_extended/server/modules/commands.lua index a8c7d6a6..39c547a9 100644 --- a/[core]/es_extended/server/modules/commands.lua +++ b/[core]/es_extended/server/modules/commands.lua @@ -313,7 +313,9 @@ if not Config.CustomInventory then arguments = { { name = "playerId", help = TranslateCap("commandgeneric_playerid"), type = "player" }, { name = "item", help = TranslateCap("command_giveitem_item"), type = "item" }, - { name = "count", help = TranslateCap("command_giveitem_count"), type = "number" }, + { name = "count", help = TranslateCap("command_giveitem_count"), type = "number", isValid = function (countValue) + return countValue > 0 + end }, }, } )