From c50419bcce963b18103c81e7fe6d943ea7d318eb Mon Sep 17 00:00:00 2001 From: Selt <83926739+seltonmt012@users.noreply.github.com> Date: Sat, 8 Aug 2026 18:40:18 +0200 Subject: [PATCH] fix(esx_mechanicjob): only report a deposit that happened putStockItems showed have_deposited outside the branch that moves the items. Depositing more than you carry printed "invalid quantity" and then told you the amount had been deposited, while nothing left the inventory. The count itself was never checked either, so a zero or negative amount reached the core, where removeInventoryItem raises on anything below one. getStockItem in the same file already has the intended shape: guard the count, report inside the branch. Measured against the shipped handler, a deposit of 50 with 10 carried now stops at "invalid quantity", and 0 and -5 no longer raise. The success path is unchanged. --- [esx_addons]/esx_mechanicjob/server/main.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/[esx_addons]/esx_mechanicjob/server/main.lua b/[esx_addons]/esx_mechanicjob/server/main.lua index c6b1f00b..b7c8951c 100644 --- a/[esx_addons]/esx_mechanicjob/server/main.lua +++ b/[esx_addons]/esx_mechanicjob/server/main.lua @@ -287,14 +287,13 @@ AddEventHandler('esx_mechanicjob:putStockItems', function(itemName, count) local item = inventory.getItem(itemName) local playerItemCount = xPlayer.getInventoryItem(itemName).count - if item.count >= 0 and count <= playerItemCount then + if count > 0 and count <= playerItemCount then xPlayer.removeInventoryItem(itemName, count) inventory.addItem(itemName, count) + xPlayer.showNotification(TranslateCap('have_deposited', count, item.label)) else xPlayer.showNotification(TranslateCap('invalid_quantity')) end - - xPlayer.showNotification(TranslateCap('have_deposited', count, item.label)) end) end)