add a new argument on the register command feature

This commit is contained in:
Debian
2025-08-30 09:01:49 +00:00
parent f75aab49de
commit ecb79506b4
2 changed files with 11 additions and 1 deletions
+8
View File
@@ -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
@@ -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 },
},
}
)