From 64759d7f2357b91f4aad17b010bd5444553d3049 Mon Sep 17 00:00:00 2001
From: DoPeMan17 <53881379+DoPeMan17@users.noreply.github.com>
Date: Mon, 30 Mar 2020 11:10:33 +0200
Subject: [PATCH] Add files via upload
---
__resource.lua | 4 +-
client/main.lua | 53 ++++++++-----
config.lua | 44 +++++------
esx_illegal.sql | 24 ++++++
locales/en.lua | 32 ++++----
main.lua | 175 +++++++++++++++++++++++++++++++++++++++++++
server/chemicals.lua | 7 +-
server/coke.lua | 25 ++++---
server/heroin.lua | 25 ++++---
server/lsd.lua | 40 +++++-----
server/main.lua | 8 +-
server/meth.lua | 47 ++++++------
server/weed.lua | 27 +++----
13 files changed, 361 insertions(+), 150 deletions(-)
create mode 100644 esx_illegal.sql
create mode 100644 main.lua
diff --git a/__resource.lua b/__resource.lua
index de2af8e..6f02d32 100644
--- a/__resource.lua
+++ b/__resource.lua
@@ -1,8 +1,8 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
-description 'ESX Drugs by DoPeMan'
+description 'ESX Illegal'
-version '1.0.0'
+version '2.0.0'
server_scripts {
'@mysql-async/lib/MySQL.lua',
diff --git a/client/main.lua b/client/main.lua
index 8bad1b4..6dc127f 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -42,14 +42,15 @@ Citizen.CreateThread(function()
OpenDrugShop()
end
else
- Citizen.Wait(0)
+ Citizen.Wait(500)
end
- else
+ --[[else
if wasOpen then
wasOpen = false
ESX.UI.Menu.CloseAll()
end
- Citizen.Wait(0)
+
+ Citizen.Wait(500)--]]
end
end
end)
@@ -139,24 +140,36 @@ function OpenBuyLicenseMenu(licenseName)
end)
end
-function CreateBlipCircle(coords, text, radius, color, sprite)
- local blip = AddBlipForRadius(coords, radius)
- SetBlipHighDetail(blip, true)
- SetBlipColour(blip, 1)
- SetBlipAlpha (blip, 128)
- -- create a blip in the middle
- blip = AddBlipForCoord(coords)
- SetBlipHighDetail(blip, true)
- SetBlipSprite (blip, sprite)
- SetBlipScale (blip, 1.0)
- SetBlipColour (blip, color)
- SetBlipAsShortRange(blip, true)
- BeginTextCommandSetBlipName("STRING")
- AddTextComponentString(text)
- EndTextCommandSetBlipName(blip)
+function CreateBlipCircle(coords, text, radius, color, sprite)
+
+ if Config.EnableMapsBlimps then
+ local blip = AddBlipForRadius(coords, radius)
+
+ SetBlipHighDetail(blip, true)
+ SetBlipColour(blip, 1)
+ SetBlipAlpha (blip, 128)
+
+ -- create a blip in the middle
+ blip = AddBlipForCoord(coords)
+
+ SetBlipHighDetail(blip, true)
+ SetBlipSprite (blip, sprite)
+ SetBlipScale (blip, 1.0)
+ SetBlipColour (blip, color)
+ SetBlipAsShortRange(blip, true)
+
+ BeginTextCommandSetBlipName("STRING")
+ AddTextComponentString(text)
+ EndTextCommandSetBlipName(blip)
+ end
end
+
Citizen.CreateThread(function()
- for k,zone in pairs(Config.CircleZones) do
- CreateBlipCircle(zone.coords, zone.name, zone.radius, zone.color, zone.sprite)
+ if Config.EnableMapsBlimps then
+ for k,zone in pairs(Config.CircleZones) do
+ if zone.enabled then
+ CreateBlipCircle(zone.blimpcoords, zone.name, zone.radius, zone.color, zone.sprite)
+ end
+ end
end
end)
\ No newline at end of file
diff --git a/config.lua b/config.lua
index 63680c0..70eb99b 100644
--- a/config.lua
+++ b/config.lua
@@ -26,8 +26,8 @@ Config.ChemicalsConvertionItems = {
lsa = 0,
}
-Config.ChemicalsLicenseEnabled = false --Will Enable or Disable the need for a Chemicals License.
-Config.MoneyWashLicenseEnabled = false --Will Enable or Disable the need for a MoneyWash License.
+Config.ChemicalsLicenseEnabled = true --Will Enable or Disable the need for a Chemicals License.
+Config.MoneyWashLicenseEnabled = true --Will Enable or Disable the need for a MoneyWash License.
Config.LicensePrices = {
weed_processing = {label = _U('license_weed'), price = 15000}
@@ -40,39 +40,41 @@ Config.Licenses = {
Config.GiveBlack = true -- give black money? if disabled it'll give regular cash.
+Config.EnableMapsBlimps = true -- Enables the blimps on the map.
+
Config.CircleZones = {
--Weed
- WeedField = {coords = vector3(2224.64, 5577.03, 53.85), name = _U('blip_WeedFarm'), color = 25, sprite = 496, radius = 100.0},
- WeedProcessing = {coords = vector3(2329.12, 2571.86, 46.68), name = _U('blip_weedprocessing'), color = 25, sprite = 496, radius = 100.0},
+ WeedField = {coords = vector3(2224.64, 5577.03, 53.85), blimpcoords = vector3(2224.64, 5577.03, 53.85), name = _U('blip_weedfield'), color = 25, sprite = 496, radius = 0, enabled = true},
+ WeedProcessing = {coords = vector3(1035.86, -3205.20, -38.17), blimpcoords = vector3(-1127.86, 2708.03, 18.8), name = _U('blip_weedprocessing'), color = 25, sprite = 496, radius = 0.0, enabled = true},
--meth
- MethProcessing = {coords = vector3(1390.33, 3608.5, 38.94), name = _U('blip_methprocessing'), color = 25, sprite = 496, radius = 0.0},
- HydrochloricAcidFarm = {coords = vector3(2724.12, 1583.03, 24.5), name = _U('blip_HydrochloricAcidFarm'), color = 25, sprite = 496, radius = 7.0},
- SulfuricAcidFarm = {coords = vector3(3333.34, 5160.22, 18.31), name = _U('blip_SulfuricAcidFarm'), color = 25, sprite = 496, radius = 5.0},
- SodiumHydroxideFarm = {coords = vector3(3617.04, 3738.73, 28.69), name = _U('blip_SodiumHydroxideFarm'), color = 25, sprite = 496, radius = 7.0},
+ MethProcessing = {coords = vector3(1007.27, -3197.93, -38.99), blimpcoords = vector3(1454.78, -1651.42, 66.99), name = _U('blip_methprocessing'), color = 5, sprite = 51, radius = 0.0, enabled = true},
+ HydrochloricAcidFarm = {coords = vector3(2724.12, 1583.03, 24.5), blimpcoords = vector3(2724.12, 1583.03, 24.5), name = _U('blip_HydrochloricAcidFarm'), color = 5, sprite = 51, radius = 0.0, enabled = true},
+ SulfuricAcidFarm = {coords = vector3(3333.34, 5160.22, 18.31), blimpcoords = vector3(3333.34, 5160.22, 18.31), name = _U('blip_SulfuricAcidFarm'), color = 5, sprite = 51, radius = 0.0, enabled = true},
+ SodiumHydroxideFarm = {coords = vector3(3617.04, 3738.73, 28.69), blimpcoords = vector3(3617.04, 3738.73, 28.69), name = _U('blip_SodiumHydroxideFarm'), color = 5, sprite = 51, radius = 0.0, enabled = true},
--Chemicals
- ChemicalsField = {coords = vector3(817.46, -3192.84, 5.9), name = _U('blip_ChemicalsFarm'), color = 25, sprite = 496, radius = 0.0},
- ChemicalsConvertionMenu = {coords = vector3(3718.8, 4533.45, 21.67), name = _U('blip_ChemicalsProcessing'), color = 25, sprite = 496, radius = 0.0},
+ ChemicalsField = {coords = vector3(817.46, -3192.84, 5.9), blimpcoords = vector3(817.46, -3192.84, 5.9), name = _U('blip_ChemicalsFarm'), color = 3, sprite = 499, radius = 0.0, enabled = true},
+ ChemicalsConvertionMenu = {coords = vector3(3718.8, 4533.45, 21.67), blimpcoords = vector3(3718.8, 4533.45, 21.67), name = _U('blip_ChemicalsProcessing'), color = 3, sprite = 499, radius = 0.0, enabled = true},
--Coke
- CokeField = {coords = vector3(-310.43, 2496.34, 76.60), name = _U('blip_CokeFarm'), color = 25, sprite = 496, radius = 20.0},
- CokeProcessing = {coords = vector3(1689.14, 3291.36, 41.15), name = _U('blip_Cokeprocessing'),color = 25, sprite = 496, radius = 20.0},
+ CokeField = {coords = vector3(-310.43, 2496.34, 76.60), blimpcoords = vector3(-310.43, 2496.34, 76.60), name = _U('blip_CokeFarm'), color = 4, sprite = 501, radius = 0.0, enabled = true},
+ CokeProcessing = {coords = vector3(1090.00, -3194.93, -38.99), blimpcoords = vector3(143.66, -1656.21, 29.33), name = _U('blip_Cokeprocessing'),color = 4, sprite = 501, radius = 0.0, enabled = true},
--LSD
- lsdProcessing = {coords = vector3(91.26, 3749.31, 40.77), name = _U('blip_lsdprocessing'),color = 25, sprite = 496, radius = 20.0},
- thionylchlorideProcessing = {coords = vector3(1903.98, 4922.70, 48.16), name = _U('blip_lsdprocessing'),color = 25, sprite = 496, radius = 20.0},
+ lsdProcessing = {coords = vector3(91.26, 3749.31, 40.77), blimpcoords = vector3(91.26, 3749.31, 40.77), name = _U('blip_lsdprocessing'),color = 12, sprite = 364, radius = 0.0, enabled = true},
+ thionylchlorideProcessing = {coords = vector3(1903.98, 4922.70, 48.16), blimpcoords = vector3(1903.98, 4922.70, 48.16), name = _U('blip_thionylchlorideprocessing'),color = 12, sprite = 364, radius = 0.0, enabled = true},
--Heroin
- HeroinField = {coords = vector3(16.34, 6875.94, 12.64), name = _U('blip_heroinfield'), color = 25, sprite = 496, radius = 20},
- HeroinProcessing = {coords = vector3(-65.43, 6243.36, 31.08), name = _U('blip_heroinprocessing'), color = 25, sprite = 496, radius = 100.0},
+ HeroinField = {coords = vector3(16.34, 6875.94, 12.64), blimpcoords = vector3(16.34, 6875.94, 12.64), name = _U('blip_heroinfield'), color = 7, sprite = 497, radius = 0, enabled = true},
+ HeroinProcessing = {coords = vector3(-62.15, 6391.40, 31.49), blimpcoords = vector3(-62.15, 6391.40, 31.49), name = _U('blip_heroinprocessing'), color = 7, sprite = 497, radius = 0.0, enabled = true},
- --DrugDealer
- DrugDealer = {coords = vector3(-1172.02, -1571.98, 4.66), name = _U('blip_drugdealer'), color = 6, sprite = 378, radius = 25.0},
-
--License
- LicenseShop = {coords = vector3(707.17, -962.5, 30.4), name = _U('blip_lsdprocessing'),color = 25, sprite = 496, radius = 20.0},
+ LicenseShop = {coords = vector3(707.17, -962.5, 30.4), blimpcoords = vector3(707.17, -962.5, 30.4), name = _U('blip_licenseshop'),color = 9, sprite = 498, radius = 0.0, enabled = true},
+
+ --DrugDealer
+ DrugDealer = {coords = vector3(-1172.02, -1571.98, 4.66), blimpcoords = vector3(-1172.02, -1571.98, 4.66), name = _U('blip_drugdealer'), color = 6, sprite = 378, radius = 0.0, enabled = true},
--MoneyWash
- MoneyWash = {coords = vector3(8.84, -1103.8, -29.8), name = _U('blip_drugdealer'), color = 6, sprite = 378, radius = 25.0},
+ MoneyWash = {coords = vector3(1119.87, -3195.44, -39.40), blimpcoords = vector3(48.83, 6305.34, 31.36), name = _U('blip_moneywash'), color = 1, sprite = 500, radius = 0.0, enabled = true},
}
diff --git a/esx_illegal.sql b/esx_illegal.sql
new file mode 100644
index 0000000..02eb4c5
--- /dev/null
+++ b/esx_illegal.sql
@@ -0,0 +1,24 @@
+USE `essentialmode`;
+
+INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
+ ('cannabis', 'Cannabis', 3, 0, 1),
+ ('marijuana', 'Marijuana', 2, 0, 1),
+ ('chemicals', 'Chemicals', 0.5, 0, 1),
+ ('chemicalslisence', 'Chemicals license', 0, 0, 1),
+ ('moneywash', 'MoneyWash License', 0, 0, 1),
+ ('coca_leaf', 'Coca Leaf', 3, 0, 1),
+ ('coke', 'Coke', 3, 0, 1),
+ ('poppyresin', 'Poppy Resin', 0.5, 0, 1),
+ ('heroin', 'Heroin', 2, 0, 1),
+ ('lsa', 'LSA', 1, 0, 1),
+ ('lsd', 'LSD', 1, 0, 1),
+ ('meth', 'Meth', 3, 0, 1),
+ ('hydrochloric_acid', 'HydroChloric Acid', 2, 0, 1),
+ ('sodium_hydroxide', 'Sodium Hydroxide', 2, 0, 1),
+ ('sulfuric_acid', 'Sulfuric Acid', 2, 0, 1),
+ ('thionyl_chloride', 'Thionyl Chloride', 0.5, 0, 1)
+;
+
+INSERT INTO `licenses` (`type`, `label`) VALUES
+ ('weed_processing', 'Weed Processing License')
+;
\ No newline at end of file
diff --git a/locales/en.lua b/locales/en.lua
index 9402238..eae7bf3 100644
--- a/locales/en.lua
+++ b/locales/en.lua
@@ -95,20 +95,22 @@ Locales ['en'] = {
['moneywash_prompt'] = 'press ~INPUT_CONTEXT~ to open the ~r~MoneyWash~s~.',
-- blips
- ['blip_weedfield'] = 'weed Field',
- ['blip_weedprocessing'] = 'weed Processing',
- ['blip_methfield'] = 'meth Field',
- ['blip_methprocessing'] = 'meth Processing',
- ['blip_drugdealer'] = 'drug Dealer',
- ['blip_ChemicalsProcessing'] = 'Chemische Verarbeitung',
- ['blip_ChemicalsFarm'] = 'Chemiefarm',
- ['blip_CokeFarm'] = 'Koks Farm',
- ['blip_Cokeprocessing'] = 'Koks Herstellung',
- ['blip_herionfield'] = 'Heroin Farm',
- ['blip_heroinprocessing'] = 'Heroin Herstellung',
- ['blip_HydrochloricAcidFarm'] = 'SalzsƤure Bauernhof',
- ['blip_lsdprocessing'] = 'LSD Herstellung',
+ ['blip_weedfield'] = 'Weed Field',
+ ['blip_weedprocessing'] = 'Weed Processing',
+ ['blip_HydrochloricAcidFarm'] = 'Hydrochloric Acid Farm',
+ ['blip_SulfuricAcidFarm'] = 'Sulfuric Acid Farm',
['blip_SodiumHydroxideFarm'] = 'Sodium Hydroxide Farm',
- ['blip_SulfuricAcidFarm'] = 'SulfuricAcidFarm',
-}
+ ['blip_ChemicalsFarm'] = 'Chemicals Farm',
+ ['blip_ChemicalsProcessing'] = 'Chemicals Processing',
+ ['blip_CokeFarm'] = 'Coca Field',
+ ['blip_Cokeprocessing'] = 'Coke Processing',
+ ['blip_lsdprocessing'] = 'lsd Processing',
+ ['blip_thionylchlorideprocessing'] = 'Thionyl Chloride Processing',
+ ['blip_heroinfield'] = 'Ploppy Field',
+ ['blip_heroinprocessing'] = 'Heroin Processing',
+ ['blip_licenseshop'] = 'License Shop',
+ ['blip_moneywash'] = 'MoneyWash',
+ ['blip_methprocessing'] = 'Meth Processing',
+ ['blip_drugdealer'] = 'Drug Dealer',
+}
diff --git a/main.lua b/main.lua
new file mode 100644
index 0000000..7ca0119
--- /dev/null
+++ b/main.lua
@@ -0,0 +1,175 @@
+Keys = {
+ ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
+ ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
+ ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
+ ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
+ ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
+ ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
+ ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
+ ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
+ ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
+}
+
+ESX = nil
+local menuOpen = false
+local wasOpen = false
+
+Citizen.CreateThread(function()
+ while ESX == nil do
+ TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
+ Citizen.Wait(0)
+ end
+
+ while ESX.GetPlayerData().job == nil do
+ Citizen.Wait(100)
+ end
+
+ ESX.PlayerData = ESX.GetPlayerData()
+end)
+
+Citizen.CreateThread(function()
+ while true do
+ Citizen.Wait(0)
+ local playerPed = PlayerPedId()
+ local coords = GetEntityCoords(playerPed)
+
+ if GetDistanceBetweenCoords(coords, Config.CircleZones.DrugDealer.coords, true) < 1.50 then
+ if not menuOpen then
+ ESX.ShowHelpNotification(_U('dealer_prompt'))
+
+ if IsControlJustReleased(0, Keys['E']) then
+ wasOpen = true
+ OpenDrugShop()
+ end
+ else
+ Citizen.Wait(500)
+ end
+ --[[else
+ if wasOpen then
+ wasOpen = false
+ ESX.UI.Menu.CloseAll()
+ end
+
+ Citizen.Wait(500)--]]
+ end
+ end
+end)
+
+function OpenDrugShop()
+ ESX.UI.Menu.CloseAll()
+ local elements = {}
+ menuOpen = true
+
+ for k, v in pairs(ESX.GetPlayerData().inventory) do
+ local price = Config.DrugDealerItems[v.name]
+
+ if price and v.count > 0 then
+ table.insert(elements, {
+ label = ('%s - %s'):format(v.label, _U('dealer_item', ESX.Math.GroupDigits(price))),
+ name = v.name,
+ price = price,
+
+ -- menu properties
+ type = 'slider',
+ value = v.count,
+ min = 1,
+ max = v.count
+ })
+ end
+ end
+
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'drug_shop', {
+ title = _U('dealer_title'),
+ align = 'top-left',
+ elements = elements
+ }, function(data, menu)
+ TriggerServerEvent('esx_illegal:sellDrug', data.current.name, data.current.value)
+ end, function(data, menu)
+ menu.close()
+ menuOpen = false
+ end)
+end
+
+AddEventHandler('onResourceStop', function(resource)
+ if resource == GetCurrentResourceName() then
+ if menuOpen then
+ ESX.UI.Menu.CloseAll()
+ end
+ end
+end)
+
+function OpenBuyLicenseMenu(licenseName)
+ menuOpen = true
+ local license = Config.LicensePrices[licenseName]
+
+ local elements = {
+ {
+ label = _U('license_no'),
+ value = 'no'
+ },
+
+ {
+ label = ('%s - %s'):format(license.label, _U('dealer_item', ESX.Math.GroupDigits(license.price))),
+ value = licenseName,
+ price = license.price,
+ licenseName = license.label
+ }
+ }
+
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'license_shop', {
+ title = _U('license_title'),
+ align = 'top-left',
+ elements = elements
+ }, function(data, menu)
+
+ if data.current.value ~= 'no' then
+ ESX.TriggerServerCallback('esx_illegal:buyLicense', function(boughtLicense)
+ if boughtLicense then
+ ESX.ShowNotification(_U('license_bought', data.current.licenseName, ESX.Math.GroupDigits(data.current.price)))
+ else
+ ESX.ShowNotification(_U('license_bought_fail', data.current.licenseName))
+ end
+ end, data.current.value)
+ else
+ menu.close()
+ end
+
+ end, function(data, menu)
+ menu.close()
+ menuOpen = false
+ end)
+end
+
+function CreateBlipCircle(coords, text, radius, color, sprite)
+
+ if Config.EnableMapsBlimps then
+ local blip = AddBlipForRadius(coords, radius)
+
+ SetBlipHighDetail(blip, true)
+ SetBlipColour(blip, 1)
+ SetBlipAlpha (blip, 128)
+
+ -- create a blip in the middle
+ blip = AddBlipForCoord(coords)
+
+ SetBlipHighDetail(blip, true)
+ SetBlipSprite (blip, sprite)
+ SetBlipScale (blip, 1.0)
+ SetBlipColour (blip, color)
+ SetBlipAsShortRange(blip, true)
+
+ BeginTextCommandSetBlipName("STRING")
+ AddTextComponentString(text)
+ EndTextCommandSetBlipName(blip)
+ end
+end
+
+Citizen.CreateThread(function()
+ if Config.EnableMapsBlimps then
+ for k,zone in pairs(Config.CircleZones) do
+ if zone.enabled then
+ CreateBlipCircle(zone.coords, zone.name, zone.radius, zone.color, zone.sprite)
+ end
+ end
+ end
+end)
\ No newline at end of file
diff --git a/server/chemicals.lua b/server/chemicals.lua
index 4238241..0a08d4d 100644
--- a/server/chemicals.lua
+++ b/server/chemicals.lua
@@ -3,12 +3,11 @@ local playersProcessingChemicalsToHydrochloricAcid = {}
RegisterServerEvent('esx_illegal:pickedUpChemicals')
AddEventHandler('esx_illegal:pickedUpChemicals', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('chemicals')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('Chemicals_inventoryfull'))
+ if xPlayer.canCarryItem('chemicals', 1) then
+ xPlayer.addInventoryItem('chemicals', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('Chemicals_inventoryfull'))
end
end)
diff --git a/server/coke.lua b/server/coke.lua
index 1a176ed..fb9d59a 100644
--- a/server/coke.lua
+++ b/server/coke.lua
@@ -3,12 +3,11 @@ local playersProcessingCocaLeaf = {}
RegisterServerEvent('esx_illegal:pickedUpCocaLeaf')
AddEventHandler('esx_illegal:pickedUpCocaLeaf', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('coca_leaf')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('coca_leaf_inventoryfull'))
+ if xPlayer.canCarryItem('coca_leaf', 1) then
+ xPlayer.addInventoryItem('coca_leaf', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('coca_leaf_inventoryfull'))
end
end)
@@ -21,15 +20,17 @@ AddEventHandler('esx_illegal:processCocaLeaf', function()
local xPlayer = ESX.GetPlayerFromId(_source)
local xCocaLeaf, xCoke = xPlayer.getInventoryItem('coca_leaf'), xPlayer.getInventoryItem('coke')
- if xCoke.limit ~= -1 and (xCoke.count + 1) > xCoke.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('coke_processingfull'))
- elseif xCocaLeaf.count < 3 then
- TriggerClientEvent('esx:showNotification', _source, _U('coke_processingenough'))
- else
- xPlayer.removeInventoryItem('coca_leaf', 3)
- xPlayer.addInventoryItem('coke', 1)
+ if xCocaLeaf.count > 3 then
+ if xPlayer.canSwapItem('coca_leaf', 3, 'coke', 1) then
+ xPlayer.removeInventoryItem('coca_leaf', 3)
+ xPlayer.addInventoryItem('coke', 1)
- TriggerClientEvent('esx:showNotification', _source, _U('coke_processed'))
+ xPlayer.showNotification(_U('coke_processed'))
+ else
+ xPlayer.showNotification(_U('coke_processingfull'))
+ end
+ else
+ xPlayer.showNotification(_U('coke_processingenough'))
end
playersProcessingCocaLeaf[_source] = nil
diff --git a/server/heroin.lua b/server/heroin.lua
index d299a25..4c6c279 100644
--- a/server/heroin.lua
+++ b/server/heroin.lua
@@ -3,12 +3,11 @@ local playersProcessingPoppyResin = {}
RegisterServerEvent('esx_illegal:pickedUpPoppy')
AddEventHandler('esx_illegal:pickedUpPoppy', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('poppyresin')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('poppy_inventoryfull'))
+ if xPlayer.canCarryItem('poppyresin', 1) then
+ xPlayer.addInventoryItem('poppyresin', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('poppy_inventoryfull'))
end
end)
@@ -21,15 +20,17 @@ AddEventHandler('esx_illegal:processPoppyResin', function()
local xPlayer = ESX.GetPlayerFromId(_source)
local xPoppyResin, xHeroin = xPlayer.getInventoryItem('poppyresin'), xPlayer.getInventoryItem('heroin')
- if xHeroin.limit ~= -1 and (xHeroin.count + 1) > xHeroin.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('heroin_processingfull'))
- elseif xPoppyResin.count < 1 then
- TriggerClientEvent('esx:showNotification', _source, _U('heroin_processingenough'))
- else
- xPlayer.removeInventoryItem('poppyresin', 1)
- xPlayer.addInventoryItem('heroin', 1)
+ if xPoppyResin.count > 0 then
+ if xPlayer.canSwapItem('poppyresin', 1, 'heroin', 1) then
+ xPlayer.removeInventoryItem('poppyresin', 1)
+ xPlayer.addInventoryItem('heroin', 1)
- TriggerClientEvent('esx:showNotification', _source, _U('heroin_processed'))
+ xPlayer.showNotification(_U('heroin_processed'))
+ else
+ xPlayer.showNotification(_U('heroin_processingfull'))
+ end
+ else
+ xPlayer.showNotification(_U('heroin_processingenough'))
end
playersProcessingPoppyResin[_source] = nil
diff --git a/server/lsd.lua b/server/lsd.lua
index 3ed9b3c..05c56ee 100644
--- a/server/lsd.lua
+++ b/server/lsd.lua
@@ -9,16 +9,18 @@ AddEventHandler('esx_illegal:processLSD', function()
local xPlayer = ESX.GetPlayerFromId(_source)
local xLSA, xThionylChloride, xLSD = xPlayer.getInventoryItem('lsa'), xPlayer.getInventoryItem('thionyl_chloride'), xPlayer.getInventoryItem('lsd')
- if xLSD.limit ~= -1 and (xLSD.count + 1) > xLSD.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('lsd_processingfull'))
- elseif xLSA.count < 1 and xThionylChloride.count < 1 then
- TriggerClientEvent('esx:showNotification', _source, _U('lsd_processingenough'))
- else
- xPlayer.removeInventoryItem('lsa', 1)
- xPlayer.removeInventoryItem('thionyl_chloride', 1)
- xPlayer.addInventoryItem('lsd', 1)
+ if xLSA.count > 0 and xThionylChloride.count > 0 then
+ if xPlayer.canSwapItem('lsa', 1, 'lsd', 1) and xPlayer.canSwapItem('thionyl_chloride', 1, 'lsd', 1) then
+ xPlayer.removeInventoryItem('lsa', 1)
+ xPlayer.removeInventoryItem('thionyl_chloride', 1)
+ xPlayer.addInventoryItem('lsd', 1)
- TriggerClientEvent('esx:showNotification', _source, _U('lsd_processed'))
+ xPlayer.showNotification(_U('lsd_processed'))
+ else
+ xPlayer.showNotification(_U('lsd_processingfull'))
+ end
+ else
+ xPlayer.showNotification(_U('lsd_processingenough'))
end
playersProcessingLSD[_source] = nil
@@ -37,16 +39,18 @@ AddEventHandler('esx_illegal:processThionylChloride', function()
local xPlayer = ESX.GetPlayerFromId(_source)
local xLSA, xChemicals, xThionylChloride = xPlayer.getInventoryItem('lsa'), xPlayer.getInventoryItem('chemicals'), xPlayer.getInventoryItem('thionyl_chloride')
- if xThionylChloride.limit ~= -1 and (xThionylChloride.count + 1) > xThionylChloride.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('thionylchloride_processingfull'))
- elseif xLSA.count < 1 or xChemicals.count < 1 then
- TriggerClientEvent('esx:showNotification', _source, _U('thionylchloride_processingenough'))
- else
- xPlayer.removeInventoryItem('lsa', 1)
- xPlayer.removeInventoryItem('chemicals', 1)
- xPlayer.addInventoryItem('thionyl_chloride', 1)
+ if xLSA.count > 0 and xChemicals.count > 0 then
+ if xPlayer.canSwapItem('lsa', 1, 'thionyl_chloride', 1) and xPlayer.canSwapItem('chemicals', 1, 'thionyl_chloride', 1) then
+ xPlayer.removeInventoryItem('lsa', 1)
+ xPlayer.removeInventoryItem('chemicals', 1)
+ xPlayer.addInventoryItem('thionyl_chloride', 1)
- TriggerClientEvent('esx:showNotification', _source, _U('thionylchloride_processed'))
+ xPlayer.showNotification(_U('thionylchloride_processed'))
+ else
+ xPlayer.showNotification(_U('thionylchloride_processingfull'))
+ end
+ else
+ xPlayer.showNotification(_U('thionylchloride_processingenough'))
end
playersProcessingLSD[_source] = nil
diff --git a/server/main.lua b/server/main.lua
index 5611454..9a337dd 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -53,11 +53,5 @@ end)
ESX.RegisterServerCallback('esx_illegal:canPickUp', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem(item)
-
- if xItem.limit ~= -1 and xItem.count >= xItem.limit then
- cb(false)
- else
- cb(true)
- end
+ cb(xPlayer.canCarryItem(item, 1))
end)
diff --git a/server/meth.lua b/server/meth.lua
index c3d8e4b..298e9c3 100644
--- a/server/meth.lua
+++ b/server/meth.lua
@@ -3,36 +3,33 @@ local playersProcessingMeth = {}
RegisterServerEvent('esx_illegal:pickedUpHydrochloricAcid')
AddEventHandler('esx_illegal:pickedUpHydrochloricAcid', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('hydrochloric_acid')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('hydrochloric_acid_inventoryfull'))
+ if xPlayer.canCarryItem('hydrochloric_acid', 1) then
+ xPlayer.addInventoryItem('hydrochloric_acid', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('hydrochloric_acid_inventoryfull'))
end
end)
RegisterServerEvent('esx_illegal:pickedUpSodiumHydroxide')
AddEventHandler('esx_illegal:pickedUpSodiumHydroxide', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('sodium_hydroxide')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('sodium_hydroxide_inventoryfull'))
+ if xPlayer.canCarryItem('sodium_hydroxide', 1) then
+ xPlayer.addInventoryItem('sodium_hydroxide', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('sodium_hydroxide_inventoryfull'))
end
end)
RegisterServerEvent('esx_illegal:pickedUpSulfuricAcid')
AddEventHandler('esx_illegal:pickedUpSulfuricAcid', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('sulfuric_acid')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('sulfuric_acid_inventoryfull'))
+ if xPlayer.canCarryItem('sulfuric_acid', 1) then
+ xPlayer.addInventoryItem('sulfuric_acid', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('sulfuric_acid_inventoryfull'))
end
end)
@@ -45,21 +42,19 @@ AddEventHandler('esx_illegal:processMeth', function()
local xPlayer = ESX.GetPlayerFromId(_source)
local xhydrochloric_acid,xsulfuric_acid,xsodium_hydroxide,xmeth = xPlayer.getInventoryItem('hydrochloric_acid'),xPlayer.getInventoryItem('sulfuric_acid'),xPlayer.getInventoryItem('sodium_hydroxide'), xPlayer.getInventoryItem('meth')
- if xmeth.limit ~= -1 and (xmeth.count + 1) > xmeth.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('meth_processingfull'))
- elseif xhydrochloric_acid.count < 1 then
- TriggerClientEvent('esx:showNotification', _source, _U('meth_processingenough'))
- elseif xsulfuric_acid.count < 1 then
- TriggerClientEvent('esx:showNotification', _source, _U('meth_processingenough'))
- elseif xsodium_hydroxide.count < 1 then
- TriggerClientEvent('esx:showNotification', _source, _U('meth_processingenough'))
- else
- xPlayer.removeInventoryItem('hydrochloric_acid', 1)
- xPlayer.removeInventoryItem('sulfuric_acid', 1)
- xPlayer.removeInventoryItem('sodium_hydroxide', 1)
- xPlayer.addInventoryItem('meth', 1)
+ if xhydrochloric_acid.count > 0 and xsulfuric_acid.count > 0 and xsodium_hydroxide.count > 0 then
+ if xPlayer.canSwapItem('hydrochloric_acid', 1, 'meth', 1) and xPlayer.canSwapItem('sulfuric_acid', 1, 'meth', 1) and xPlayer.canSwapItem('sodium_hydroxide', 1, 'meth', 1) then
+ xPlayer.removeInventoryItem('hydrochloric_acid', 1)
+ xPlayer.removeInventoryItem('sulfuric_acid', 1)
+ xPlayer.removeInventoryItem('sodium_hydroxide', 1)
+ xPlayer.addInventoryItem('meth', 1)
- TriggerClientEvent('esx:showNotification', _source, _U('meth_processed'))
+ xPlayer.showNotification(_U('meth_processed'))
+ else
+ xPlayer.showNotification(_U('meth_processingfull'))
+ end
+ else
+ xPlayer.showNotification(_U('meth_processingenough'))
end
playersProcessingMeth[_source] = nil
diff --git a/server/weed.lua b/server/weed.lua
index 70d7f0a..ee3a25a 100644
--- a/server/weed.lua
+++ b/server/weed.lua
@@ -3,12 +3,11 @@ local playersProcessingCannabis = {}
RegisterServerEvent('esx_illegal:pickedUpCannabis')
AddEventHandler('esx_illegal:pickedUpCannabis', function()
local xPlayer = ESX.GetPlayerFromId(source)
- local xItem = xPlayer.getInventoryItem('cannabis')
- if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('weed_inventoryfull'))
+ if xPlayer.canCarryItem('cannabis', 1) then
+ xPlayer.addInventoryItem('cannabis', 1)
else
- xPlayer.addInventoryItem(xItem.name, 1)
+ xPlayer.showNotification(_U('weed_inventoryfull'))
end
end)
@@ -19,17 +18,19 @@ AddEventHandler('esx_illegal:processCannabis', function()
playersProcessingCannabis[_source] = ESX.SetTimeout(Config.Delays.WeedProcessing, function()
local xPlayer = ESX.GetPlayerFromId(_source)
- local xCannabis, xMarijuana = xPlayer.getInventoryItem('cannabis'), xPlayer.getInventoryItem('marijuana')
+ local xCannabis = xPlayer.getInventoryItem('cannabis')
- if xMarijuana.limit ~= -1 and (xMarijuana.count + 1) > xMarijuana.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('weed_processingfull'))
- elseif xCannabis.count < 2 then
- TriggerClientEvent('esx:showNotification', _source, _U('weed_processingenough'))
- else
- xPlayer.removeInventoryItem('cannabis', 2)
- xPlayer.addInventoryItem('marijuana', 1)
+ if xCannabis.count > 3 then
+ if xPlayer.canSwapItem('cannabis', 3, 'marijuana', 1) then
+ xPlayer.removeInventoryItem('cannabis', 3)
+ xPlayer.addInventoryItem('marijuana', 1)
- TriggerClientEvent('esx:showNotification', _source, _U('weed_processed'))
+ xPlayer.showNotification(_U('weed_processed'))
+ else
+ xPlayer.showNotification(_U('weed_processingfull'))
+ end
+ else
+ xPlayer.showNotification(_U('weed_processingenough'))
end
playersProcessingCannabis[_source] = nil