From 3dae29d7dc49f14c29248949152dc47d641ac8aa Mon Sep 17 00:00:00 2001 From: YOMAN1792 Date: Tue, 25 Feb 2025 15:44:09 -0500 Subject: [PATCH 1/3] Fix ox crash --- [core]/es_extended/server/modules/commands.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/[core]/es_extended/server/modules/commands.lua b/[core]/es_extended/server/modules/commands.lua index 628e85ea..a040f44d 100644 --- a/[core]/es_extended/server/modules/commands.lua +++ b/[core]/es_extended/server/modules/commands.lua @@ -204,9 +204,13 @@ ESX.RegisterCommand( "setaccountmoney", "admin", function(xPlayer, args, showError) + local MAX_AMOUNT = 1.79769e+308 if not args.playerId.getAccount(args.account) then return showError(TranslateCap("command_giveaccountmoney_invalid")) end + if args.amount > MAX_AMOUNT then + return showError(("Amount must be between 1 and %s"):format(MAX_AMOUNT)) + end args.playerId.setAccountMoney(args.account, args.amount, "Government Grant") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Set Account Money /setaccountmoney Triggered!", "pink", { @@ -234,9 +238,13 @@ ESX.RegisterCommand( "giveaccountmoney", "admin", function(xPlayer, args, showError) + local MAX_AMOUNT = 1.79769e+308 if not args.playerId.getAccount(args.account) then return showError(TranslateCap("command_giveaccountmoney_invalid")) end + if args.amount > MAX_AMOUNT then + return showError(("Amount must be between 1 and %s"):format(MAX_AMOUNT)) + end args.playerId.addAccountMoney(args.account, args.amount, "Government Grant") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Give Account Money /giveaccountmoney Triggered!", "pink", { From d9fe2d8051c82c4769b7b66502f969afd8be9d4a Mon Sep 17 00:00:00 2001 From: YOMAN1792 Date: Tue, 25 Feb 2025 15:45:27 -0500 Subject: [PATCH 2/3] Fix oc crash and the impossibility to give anymore money --- [core]/es_extended/server/modules/commands.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/[core]/es_extended/server/modules/commands.lua b/[core]/es_extended/server/modules/commands.lua index a040f44d..44cd4699 100644 --- a/[core]/es_extended/server/modules/commands.lua +++ b/[core]/es_extended/server/modules/commands.lua @@ -272,9 +272,13 @@ ESX.RegisterCommand( "removeaccountmoney", "admin", function(xPlayer, args, showError) + local MAX_AMOUNT = 1.79769e+308 if not args.playerId.getAccount(args.account) then return showError(TranslateCap("command_removeaccountmoney_invalid")) end + if args.amount > MAX_AMOUNT then + return showError(("Amount must be between 1 and %s"):format(MAX_AMOUNT)) + end args.playerId.removeAccountMoney(args.account, args.amount, "Government Tax") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Remove Account Money /removeaccountmoney Triggered!", "pink", { From 5e91bad5c4b61b37675c4752f39fa8da1e7c3b52 Mon Sep 17 00:00:00 2001 From: YOMAN1792 Date: Tue, 25 Feb 2025 15:47:32 -0500 Subject: [PATCH 3/3] feat(commands): add maximum amount validation for giveitem, giveweapon, and giveammo commands --- [core]/es_extended/server/modules/commands.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/[core]/es_extended/server/modules/commands.lua b/[core]/es_extended/server/modules/commands.lua index 44cd4699..98c9fff6 100644 --- a/[core]/es_extended/server/modules/commands.lua +++ b/[core]/es_extended/server/modules/commands.lua @@ -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", {