From 2dacb08f0ff52b165a16aa3219faceb21691d7e7 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Thu, 14 Apr 2022 23:23:30 +0100 Subject: [PATCH] Refactor! (esx_mechanicjob): Breaking - change functions to match legacy --- [esx_addons]/esx_mechanicjob/server/main.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/[esx_addons]/esx_mechanicjob/server/main.lua b/[esx_addons]/esx_mechanicjob/server/main.lua index 42246c33..9981d5f6 100644 --- a/[esx_addons]/esx_mechanicjob/server/main.lua +++ b/[esx_addons]/esx_mechanicjob/server/main.lua @@ -12,9 +12,9 @@ local function Harvest(source) if PlayersHarvesting[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local GazBottleQuantity = xPlayer.getInventoryItem('gazbottle').count + local GazBottle = xPlayer.hasItem('gazbottle') - if GazBottleQuantity >= 5 then + if GazBottle and GazBottle.count >= 5 then TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room')) else xPlayer.addInventoryItem('gazbottle', 1) @@ -44,9 +44,9 @@ local function Harvest2(source) if PlayersHarvesting2[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local FixToolQuantity = xPlayer.getInventoryItem('fixtool').count + local FixToolQuantity = xPlayer.hasItem('fixtool') - if FixToolQuantity >= 5 then + if FixToolQuantity and FixToolQuantity.count >= 5 then TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room')) else xPlayer.addInventoryItem('fixtool', 1) @@ -107,9 +107,9 @@ local function Craft(source) if PlayersCrafting[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local GazBottleQuantity = xPlayer.getInventoryItem('gazbottle').count + local GazBottleQuantity = xPlayer.hasItem('gazbottle') - if GazBottleQuantity <= 0 then + if not GazBottleQuantity then TriggerClientEvent('esx:showNotification', source, _U('not_enough_gas_can')) else xPlayer.removeInventoryItem('gazbottle', 1) @@ -140,9 +140,9 @@ local function Craft2(source) if PlayersCrafting2[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local FixToolQuantity = xPlayer.getInventoryItem('fixtool').count + local FixToolQuantity = xPlayer.hasItem('fixtool') - if FixToolQuantity <= 0 then + if not FixToolQuantity then TriggerClientEvent('esx:showNotification', source, _U('not_enough_repair_tools')) else xPlayer.removeInventoryItem('fixtool', 1)