From ecb79506b4ef3b93e2f4b3c66c1967de9b0e244b Mon Sep 17 00:00:00 2001 From: Debian Date: Sat, 30 Aug 2025 09:01:49 +0000 Subject: [PATCH] add a new argument on the register command feature --- [core]/es_extended/server/functions.lua | 8 ++++++++ [core]/es_extended/server/modules/commands.lua | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 }, }, } )