feat(commands): add max amount validation for giveitem, giveweapon, and giveammo

This commit is contained in:
YOMAN1792
2025-02-25 15:47:32 -05:00
parent 91e783c9e9
commit a0389d7e51
@@ -307,6 +307,10 @@ if not Config.CustomInventory then
"giveitem",
"admin",
function(xPlayer, args)
local MAX_AMOUNT = 1.79769e+308
if args.amount > MAX_AMOUNT then
return showError(("Amount must be between 1 and %s"):format(MAX_AMOUNT))
end
args.playerId.addInventoryItem(args.item, args.count)
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Give Item /giveitem Triggered!", "pink", {
@@ -334,9 +338,13 @@ if not Config.CustomInventory then
"giveweapon",
"admin",
function(xPlayer, args, showError)
local MAX_AMOUNT = 1.79769e+308
if args.playerId.hasWeapon(args.weapon) then
return showError(TranslateCap("command_giveweapon_hasalready"))
end
if args.amount > MAX_AMOUNT then
return showError(("Amount must be between 1 and %s"):format(MAX_AMOUNT))
end
args.playerId.addWeapon(args.weapon, args.ammo)
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Give Weapon /giveweapon Triggered!", "pink", {
@@ -364,9 +372,13 @@ if not Config.CustomInventory then
"giveammo",
"admin",
function(xPlayer, args, showError)
local MAX_AMOUNT = 1.79769e+308
if not args.playerId.hasWeapon(args.weapon) then
return showError(TranslateCap("command_giveammo_noweapon_found"))
end
if args.amount > MAX_AMOUNT then
return showError(("Amount must be between 1 and %s"):format(MAX_AMOUNT))
end
args.playerId.addWeaponAmmo(args.weapon, args.ammo)
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Give Ammunition /giveammo Triggered!", "pink", {