diff --git a/README.md b/README.md index bb1588a..0dd5146 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ start esx_drugs ### License esx_drugs - drugs job -Copyright (C) 2015-2018 Jérémie N'gadi +Copyright (C) 2015-2020 Jérémie N'gadi This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. diff --git a/server/main.lua b/server/main.lua index 7edbbf2..26c13db 100644 --- a/server/main.lua +++ b/server/main.lua @@ -76,28 +76,30 @@ AddEventHandler('esx_drugs:processCannabis', function() local xPlayer = ESX.GetPlayerFromId(_source) local xCannabis = xPlayer.getInventoryItem('cannabis') - if not xPlayer.canCarryItem('marijuana', 1) then - xPlayer.showNotification(_U('weed_processingfull')) - elseif xCannabis.count < 3 then - xPlayer.showNotification(_U('weed_processingenough')) + if xCannabis.count > 3 then + if xPlayer.canSwapItem('cannabis', 3, 'marijuana', 1) then + xPlayer.removeInventoryItem('cannabis', 3) + xPlayer.addInventoryItem('marijuana', 1) + + xPlayer.showNotification(_U('weed_processed')) + else + xPlayer.showNotification(_U('weed_processingfull')) + playersProcessingCannabis[_source] = nil + end else - xPlayer.removeInventoryItem('cannabis', 3) - xPlayer.addInventoryItem('marijuana', 1) - - xPlayer.showNotification(_U('weed_processed')) + xPlayer.showNotification(_U('weed_processingenough')) + playersProcessingCannabis[_source] = nil end - - playersProcessingCannabis[_source] = nil end) else print(('esx_drugs: %s attempted to exploit weed processing!'):format(GetPlayerIdentifiers(source)[1])) end end) -function CancelProcessing(playerID) - if playersProcessingCannabis[playerID] then - ESX.ClearTimeout(playersProcessingCannabis[playerID]) - playersProcessingCannabis[playerID] = nil +function CancelProcessing(playerId) + if playersProcessingCannabis[playerId] then + ESX.ClearTimeout(playersProcessingCannabis[playerId]) + playersProcessingCannabis[playerId] = nil end end @@ -106,8 +108,8 @@ AddEventHandler('esx_drugs:cancelProcessing', function() CancelProcessing(source) end) -AddEventHandler('esx:playerDropped', function(playerID, reason) - CancelProcessing(playerID) +AddEventHandler('esx:playerDropped', function(playerId, reason) + CancelProcessing(playerId) end) RegisterServerEvent('esx:onPlayerDeath')