--------------------------------------- -- ESX_DRUGLABS by Dividerz -- -- FOR SUPPORT: Arne#7777 on Discord -- --------------------------------------- ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) ESX.RegisterServerCallback('esx_druglabs:server:hasMethKey', function(source, cb) local sourcePlayer = ESX.GetPlayerFromId(source) if sourcePlayer.getInventoryItem('methkey').count > 0 then cb(true) else cb(false) end end) ESX.RegisterServerCallback('esx_druglabs:server:hasCokeKey', function(source, cb) local sourcePlayer = ESX.GetPlayerFromId(source) if sourcePlayer.getInventoryItem('cokekey').count > 0 then cb(true) else cb(false) end end) RegisterNetEvent('esx_druglabs:server:clearCokeStorage') AddEventHandler('esx_druglabs:server:clearCokeStorage', function(amount) local sourcePlayer = ESX.GetPlayerFromId(source) if Config.usingWeight then if sourcePlayer.canCarryItem('coke', amount) then sourcePlayer.addInventoryItem('coke', amount) sourcePlayer.showNotification("You cleared up the storage and got ~y~" .. amount .. "~w~ bags of cocaine.") else sourcePlayer.showNotification("You can't carry this amount of bags...") end else local sourceItem = sourcePlayer.getInventoryItem('coke') if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then sourcePlayer.showNotification("You can't carry any more cokebags...") else sourcePlayer.addInventoryItem('coke', amount) end end end) RegisterNetEvent('esx_druglabs:server:clearMethStorage') AddEventHandler('esx_druglabs:server:clearMethStorage', function(amount) local sourcePlayer = ESX.GetPlayerFromId(source) if Config.usingWeight then if sourcePlayer.canCarryItem('meth', amount) then sourcePlayer.addInventoryItem('meth', amount) sourcePlayer.showNotification("You cleared up the storage and got ~y~" .. amount .. "~w~ bags of meth.") else sourcePlayer.showNotification("You can't carry this amount of bags...") end else local sourceItem = sourcePlayer.getInventoryItem('meth') if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then sourcePlayer.showNotification("You can't carry any more methbags...") else sourcePlayer.addInventoryItem('meth', amount) end end end)