diff --git a/README.md b/README.md index ee13d30..07ab74d 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Coming soon... # Meth Preview https://streamable.com/0pcjlt -# Add to qb-core > shared.lua - +# older qb-core +qb-core/shared/item.lua ``` ["wet_weed"] = {["name"] = "wet_weed", ["label"] = "Moist Weed", ["weight"] = 3000, ["type"] = "item", ["image"] = "wet_weed.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["expire"] = 90, ["description"] = "Wet weed that needs to be treated!"}, ["coke"] = {["name"] = "coke", ["label"] = "Cocaine", ["weight"] = 1000, ["type"] = "item", ["image"] = "coke.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["expire"] = 90, ["description"] = "Processed cocaine"}, @@ -56,7 +56,35 @@ https://streamable.com/0pcjlt ['finescale'] = {['name'] = 'finescale', ['label'] = 'Fine Scale', ['weight'] = 200, ['type'] = 'item', ['image'] = 'finescale.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Scale Used for Fine Powders and Materials.'}, ['coke_small_brick'] = {['name'] = 'coke_small_brick', ['label'] = 'Coke Package', ['weight'] = 350, ['type'] = 'item', ['image'] = 'coke_small_brick.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Small package of cocaine, mostly used for deals and takes a lot of space'}, ``` - +# new qb-core update +qb-core/shared/item.lua +```lua + wet_weed = {name = "wet_weed", label = "Moist Weed", weight = 3000, type = "item", image = "wet_weed.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Wet weed that needs to be treated!"}, + coke = {name = "coke", label = "Cocaine", weight = 1000, type = "item", image = "coke.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Processed cocaine"}, + coca_leaf = {name = "coca_leaf", label = "Cocaine leaves", weight = 1500, type = "item", image = "coca_leaf.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Cocaine leaves that must be processed !"}, + cannabis = {name = "cannabis", label = "Cannabis", weight = 2500, type = "item", image = "cannabis.png", unique = false, useable = true, shouldClose = true, combinable = nil, expire = 90, description = "Uncured cannabis"}, + marijuana = {name = "marijuana", label = "Marijuana", weight = 500, type = "item", image = "marijuana.png", unique = false, useable = false, shouldClose = true, combinable = nil, expire = 90, description = "Some fine smelling buds."}, + chemicals = {name = "chemicals", label = "Chemicals", weight = 1500, type = "item", image = "chemicals.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Chemicals, handle with care..."}, + poppyresin = {name = "poppyresin", label = "Poppy resin", weight = 2000, type = "item", image = "poppyresin.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "It sticks to your fingers when you handle it."}, + heroin = {name = "heroin", label = "Heroin", weight = 500, type = "item", image = "heroin.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Really addictive depressant..."}, + lsa = {name = "lsa", label = "LSA", weight = 500, type = "item", image = "lsa.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Almost ready to party..."}, + lsd = {name = "lsd", label = "LSD", weight = 500, type = "item", image = "lsd.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Lets get this party started!"}, + meth = {name = "meth", label = "Meth", weight = 500, type = "item", image = "meth.png", unique = false, useable = true, shouldClose = false, combinable = nil, expire = 90, description = "Really addictive stimulant..."}, + hydrochloric_acid = {name = "hydrochloric_acid", label = "Hydrochloric Acid", weight = 1500, type = "item", image = "hydrochloric_acid.png", unique = false, useable = true, shouldClose = true, combinable = nil, expire = 90, description = "Chemicals, handle with care!"}, + sodium_hydroxide = {name = "sodium_hydroxide", label = "Sodium Hydroxide", weight = 1500, type = "item", image = "sodium_hydroxide.png", unique = false, useable = true, shouldClose = true, combinable = nil, expire = 90, description = "Chemicals, handle with care!"}, + sulfuric_acid = {name = "sulfuric_acid", label = "Sulfuric Acid", weight = 1500, type = "item", image = "sulfuric_acid.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Chemicals, handle with care!"}, + thionyl_chloride = {name = "thionyl_chloride", label = "Thionyl Chloride", weight = 1500, type = "item", image = "thionyl_chloride.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Chemicals, handle with care!"}, + liquidmix = {name = "liquidmix", label = "Liquid Chem Mix", weight = 1500, type = "item", image = "liquidmix.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Chemicals, handle with care!"}, + bakingsoda = {name = "bakingsoda", label = "Baking Soda", weight = 1500, type = "item", image = "bakingsoda.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Household Baking Soda!"}, + chemicalvapor = {name = "chemicalvapor", label = "Chemical Vapors", weight = 1500, type = "item", image = "chemicalvapor.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "High Pressure Chemical Vapors, Explosive!"}, + trimming_scissors = {name = "trimming_scissors", label = "Trimming Scissors", weight = 1500, type = "item", image = "trimming_scissors.png", unique = false, useable = false, shouldClose = false, combinable = nil, expire = 90, description = "Very Sharp Trimming Scissors"}, + methtray = {name = 'methtray', label = 'Meth Tray', weight = 200, type = 'item', image = 'meth_tray.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'make some meth'}, + methkey = {name = 'methkey', label = 'Key A', weight = 200, type = 'item', image = 'keya.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Random Key, with "Walter" Engraved on the Back...'}, + cocainekey = {name = 'cocainekey', label = 'Key B', weight = 200, type = 'item', image = 'keyb.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Random Key, with a "Razorblade" Engraved on the Back...'}, + weedkey = {name = 'weedkey', label = 'Key C', weight = 200, type = 'item', image = 'keyc.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Random Key, with a "Seed" Engraved on the Back...'}, + finescale = {name = 'finescale', label = 'Fine Scale', weight = 200, type = 'item', image = 'finescale.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Scale Used for Fine Powders and Materials.'}, + coke_small_brick = {name = 'coke_small_brick', label = 'Coke Package', weight = 350, type = 'item', image = 'coke_small_brick.png', unique = false, useable = false, shouldClose = true, combinable = nil, description = 'Small package of cocaine, mostly used for deals and takes a lot of space'}, +``` # Add icon images diff --git a/client/chemicals.lua b/client/chemicals.lua index 0de870d..77364fa 100644 --- a/client/chemicals.lua +++ b/client/chemicals.lua @@ -1,8 +1,5 @@ -local QBCore = exports['qb-core']:GetCoreObject() -local inChemicalField = false -local SpawnedChemicals = 0 -local Chemicals = {} +local Chemicals = {} -- Chemical Menu Trigger & Menu Button Triggers -- local function createChemicalMenu() local chemMenu = { @@ -11,32 +8,44 @@ local function createChemicalMenu() header = Lang:t("menu.chemMenuHeader") }, { + icon = ps.getImage('hydrochloric_acid'), header = Lang:t("items.hydrochloric_acid"), txt = Lang:t("menu.chemicals"), - params = { - event = "ps-drugprocessing:hydrochloric_acid", - } + disabled = not ps.hasItem('chemicals'), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 10000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processHydrochloric_acid') + end }, { + icon = ps.getImage('sodium_hydroxide'), header = Lang:t("items.sodium_hydroxide"), txt = Lang:t("menu.chemicals"), - params = { - event = "ps-drugprocessing:sodium_hydroxide", - } - }, + disabled = not ps.hasItem('chemicals'), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 10000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processsodium_hydroxide') + end + }, { + icon = ps.getImage('sulfuric_acid'), header = Lang:t("items.sulfuric_acid"), txt = Lang:t("menu.chemicals"), - params = { - event = "ps-drugprocessing:sulfuric_acid", - } - }, + disabled = not ps.hasItem('chemicals'), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 10000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processprocess_sulfuric_acid') + end + }, { + icon = ps.getImage('lsa'), header = Lang:t("items.lsa"), txt = Lang:t("menu.chemicals"), - params = { - event = "ps-drugprocessing:lsa", - } + disabled = not ps.hasItem('chemicals'), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 10000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:process_lsa') + end }, { header = Lang:t("menu.close"), @@ -48,201 +57,20 @@ local function createChemicalMenu() } exports['qb-menu']:openMenu(chemMenu) end -RegisterNetEvent('ps-drugprocessing:chemicalmenu', createChemicalMenu) - --------------------------------------------------------------------- -local function ValidatechemicalsCoord(plantCoord) - local validate = true - if SpawnedChemicals > 0 then - for _, v in pairs(Chemicals) do - if #(plantCoord-GetEntityCoords(v)) < 5 then - validate = false - end - end - if not inChemicalField then - validate = false - end - end - return validate -end - -local function GetCoordZChemicals(x, y) - local groundCheckHeights = { 1, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 315.0, 320.0 } - - for i, height in ipairs(groundCheckHeights) do - local foundGround, z = GetGroundZFor_3dCoord(x, y, height) - if foundGround then - return z - end - end - - return 5.9 -end - -local function GeneratechemicalsCoords() - while inChemicalField do - Wait(1) - - local chemicalsCoordX, chemicalsCoordY - - math.randomseed(GetGameTimer()) - local modX = math.random(-20, 20) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY = math.random(-20, 20) - - chemicalsCoordX = Config.CircleZones.ChemicalsField.coords.x + modX - chemicalsCoordY = Config.CircleZones.ChemicalsField.coords.y + modY - - local coordZ = GetCoordZChemicals(chemicalsCoordX, chemicalsCoordY) - local coord = vector3(chemicalsCoordX, chemicalsCoordY, coordZ) - - if ValidatechemicalsCoord(coord) then - return coord - end - end -end - -local function SpawnChemicals() - local model = `mw_chemical_barrel` - while SpawnedChemicals < 10 do - Wait(0) - local chemicalsCoords = GeneratechemicalsCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) - end - local obj = CreateObject(model, chemicalsCoords.x, chemicalsCoords.y, chemicalsCoords.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(Chemicals, obj) - SpawnedChemicals += 1 - end - SetModelAsNoLongerNeeded(model) -end - -local function process_hydrochloric_acid() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processHydrochloric_acid') - - local timeLeft = Config.Delays.thionylchlorideProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.ChemicalsConvertionMenu.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -local function process_lsa() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:process_lsa') - - local timeLeft = Config.Delays.thionylchlorideProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.ChemicalsConvertionMenu.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -local function process_sulfuric_acid() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processprocess_sulfuric_acid') - - local timeLeft = Config.Delays.thionylchlorideProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.ChemicalsConvertionMenu.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -local function process_sodium_hydroxide() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processsodium_hydroxide') - - local timeLeft = Config.Delays.thionylchlorideProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.ChemicalsConvertionMenu.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(PlayerPedId()) - isProcessing = false - end, function() - ClearPedTasks(PlayerPedId()) - isProcessing = false - end) -end +ps.boxTarget('chemmenu', vector3(3535.66, 3661.69, 28.12), { + length = 1.0, + width = 1.0, + rotation = 0, + height = 1.0, + }, { + { + icon = "fas fa-vials", + label = Lang:t("target.chemmenu"), + action = function() + createChemicalMenu() + end, + }, + }) AddEventHandler('onResourceStop', function(resource) if resource == GetCurrentResourceName() then @@ -253,95 +81,50 @@ AddEventHandler('onResourceStop', function(resource) end end) -RegisterNetEvent("ps-drugprocessing:hydrochloric_acid", function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result then - process_hydrochloric_acid() - else - QBCore.Functions.Notify(Lang:t("error.no_chemicals"), 'error') - end - end, {chemicals = 1}) -end) - -RegisterNetEvent("ps-drugprocessing:lsa", function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result then - process_lsa() - else - QBCore.Functions.Notify(Lang:t("error.no_chemicals"), 'error') - end - end, {chemicals = 1}) -end) - -RegisterNetEvent("ps-drugprocessing:sulfuric_acid", function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result then - process_sulfuric_acid() - else - QBCore.Functions.Notify(Lang:t("error.no_chemicals"), 'error') - end - end, {chemicals = 1}) -end) - -RegisterNetEvent("ps-drugprocessing:sodium_hydroxide", function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result then - process_sodium_hydroxide() - else - QBCore.Functions.Notify(Lang:t("error.no_chemicals"), 'error') - end - end, {chemicals=1}) -end) - -RegisterNetEvent("ps-drugprocessing:pickChemicals", function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local nearbyObject, nearbyID - - for i=1, #Chemicals, 1 do - if #(coords-GetEntityCoords(Chemicals[i])) < 2 then - nearbyObject, nearbyID = Chemicals[i], i +CreateThread(function() + for k, v in pairs(GlobalState.psChem) do + if not v.taken then + local model = GetHashKey(v.model) + ps.requestModel(model) + Chemicals[k] = CreateObject(model, v.loc.x, v.loc.y, v.loc.z, false, true, false) + PlaceObjectOnGroundProperly(Chemicals[k]) + FreezeEntityPosition(Chemicals[k], true) + ps.entityTarget(Chemicals[k], { + { + icon = "fas fa-vials", + label = Lang:t("target.chemicals"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpChemicals', k) + end, + }, + }) end end +end) - if nearbyObject and IsPedOnFoot(playerPed) then - isPickingUp = true - TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false) - - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.pickup_chemicals"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done - ClearPedTasks(playerPed) - SetEntityAsMissionEntity(nearbyObject, false, true) - DeleteObject(nearbyObject) - - table.remove(Chemicals, nearbyID) - SpawnedChemicals -= 1 - - TriggerServerEvent('ps-drugprocessing:pickedUpChemicals') - isPickingUp = false - - end, function() - ClearPedTasks(playerPed) - isPickingUp = false - end) +RegisterNetEvent('ps-drugprocessing:removeChem', function(location) + if Chemicals[location] then + SetEntityAsMissionEntity(Chemicals[location], false, true) + DeleteObject(Chemicals[location]) + Chemicals[location] = nil end end) -CreateThread(function() - local chemZone = CircleZone:Create(Config.CircleZones.ChemicalsField.coords, 50.0, { - name = "ps-chemzone", - debugPoly = false +RegisterNetEvent('ps-drugprocessing:addChem', function(location) + local model = GetHashKey(GlobalState.psChem[location].model) + ps.requestModel(model) + Chemicals[location] = CreateObject(model, GlobalState.psChem[location].loc.x, GlobalState.psChem[location].loc.y, GlobalState.psChem[location].loc.z, false, true, false) + PlaceObjectOnGroundProperly(Chemicals[location]) + FreezeEntityPosition(Chemicals[location], true) + ps.entityTarget(Chemicals[location], { + { + icon = "fas fa-vials", + label = Lang:t("target.chemicals"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpChemicals', location) + end, + }, }) - chemZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inChemicalField = true - SpawnChemicals() - else - inChemicalField = false - end - end) -end) +end) \ No newline at end of file diff --git a/client/coke.lua b/client/coke.lua index 7bca6ac..72a5a7c 100644 --- a/client/coke.lua +++ b/client/coke.lua @@ -1,27 +1,10 @@ -local QBCore = exports['qb-core']:GetCoreObject() -local spawnedCocaLeaf = 0 -local CocaPlants = {} -local isPickingUp, isProcessing, inCokeField = false, false, false -local function LoadAnimationDict(dict) - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - RequestAnimDict(dict) - Wait(1) - end -end +local CocaPlants = {} -local function OpenDoorAnimation() - local ped = PlayerPedId() - LoadAnimationDict("anim@heists@keycard@") - TaskPlayAnim(ped, "anim@heists@keycard@", "exit", 5.0, 1.0, -1, 16, 0, 0, 0, 0) - Wait(400) - ClearPedTasks(ped) -end local function EnterCWarehouse() local ped = PlayerPedId() - OpenDoorAnimation() + ps.playEmote('openDoor') CWarehouse = true Wait(500) DoScreenFadeOut(250) @@ -34,7 +17,7 @@ end local function ExitCWarehouse() local ped = PlayerPedId() - OpenDoorAnimation() + ps.playEmote('openDoor') CWarehouse = true Wait(500) DoScreenFadeOut(250) @@ -46,300 +29,134 @@ local function ExitCWarehouse() CWarehouse = false end -local function ProcessCoke() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processCocaLeaf') - - local timeLeft = Config.Delays.CokeProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - - if #(GetEntityCoords(playerPed)-Config.CircleZones.CokeProcessing.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - - -local function ValidateCocaLeafCoord(plantCoord) - local validate = true - if spawnedCocaLeaf > 0 then - for _, v in pairs(CocaPlants) do - if #(plantCoord - GetEntityCoords(v)) < 5 then - validate = false - end - end - if not inCokeField then - validate = false - end - end - return validate -end - -local function GetCoordZCoke(x, y) - local groundCheckHeights = { 1.0, 25.0, 50.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0 } - - for i, height in ipairs(groundCheckHeights) do - local foundGround, z = GetGroundZFor_3dCoord(x, y, height) - - if foundGround then - return z - end - end - - return 77 -end - -local function GenerateCocaLeafCoords() - while true do - Wait(1) - - local weedCoordX, weedCoordY - - math.randomseed(GetGameTimer()) - local modX = math.random(-35, 35) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY = math.random(-35, 35) - - weedCoordX = Config.CircleZones.CokeField.coords.x + modX - weedCoordY = Config.CircleZones.CokeField.coords.y + modY - - local coordZ = GetCoordZCoke(weedCoordX, weedCoordY) - local coord = vector3(weedCoordX, weedCoordY, coordZ) - - if ValidateCocaLeafCoord(coord) then - return coord - end - end -end - -local function SpawnCocaPlants() - local model = `h4_prop_bush_cocaplant_01` - while spawnedCocaLeaf < 15 do - Wait(0) - local weedCoords = GenerateCocaLeafCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) - end - local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(CocaPlants, obj) - spawnedCocaLeaf += 1 - end - SetModelAsNoLongerNeeded(model) -end - - -local function CutCokePowder() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processCocaPowder') - - local timeLeft = Config.Delays.CokeProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - - if #(GetEntityCoords(playerPed)-Config.CircleZones.CokeProcessing.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -local function ProcessBricks() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.packing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processCocaBrick') - - local timeLeft = Config.Delays.CokeProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - - if #(GetEntityCoords(playerPed)-Config.CircleZones.CokeBrick.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) +-- Target Stuff +local function spawnTargets() + local model = GetHashKey('a_m_m_mlcrisis_01') + ps.requestModel(model) + local ped = CreatePed(0, model, vector4(812.49, -2399.59, 23.66-1, 223.1), false, true) + SetEntityInvincible(ped, true) + SetBlockingOfNonTemporaryEvents(ped, true) + FreezeEntityPosition(ped, true) + ps.entityTarget(ped, { + { + icon = "fas fa-lock", + label = Lang:t("target.coke_lab"), + action = function() + EnterCWarehouse() + end, + }, + }) + ps.boxTarget("cokeexit", vector3(1088.56, -3187.02, -38.67), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 223.1, + }, { + { + icon = "fas fa-lock", + label = Lang:t("target.keypad"), + action = function() + ExitCWarehouse() + end, + }, + }) + ps.boxTarget('cokeleafproc', vector3(1086.2, -3194.9, -38.99), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 223.1, + }, { + { + icon = "fas fa-leaf", + label = Lang:t("target.coke_leaf_processing"), + action = function() + if not ps.progressbar('Processing Coca Leaf', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:ProcessCocaFarm') + end, + }, + }) + ps.boxTarget('cokepowderproc', vector3(1092.89, -3195.78, -38.99), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 223.1, + }, { + { + icon = "fas fa-weight-scale", + label = Lang:t("target.cokepowdercut"), + action = function() + if not ps.progressbar('Processing Coca Powder', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:ProcessCocaPowder') + end, + }, + }) + ps.boxTarget('cokebricksproc', vector3(1100.51, -3199.46, -38.93), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 223.1, + }, { + { + icon = "fas fa-weight-scale", + label = Lang:t("target.bagging"), + action = function() + if not ps.progressbar('Processing Bricks', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processCocaBrick') + end, + }, + }) end +spawnTargets() -RegisterNetEvent('ps-drugprocessing:ProcessCocaFarm', function() - local coords = GetEntityCoords(PlayerPedId()) - - if #(coords-Config.CircleZones.CokeProcessing.coords) < 5 then - if not isProcessing then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessCoke() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {coca_leaf = Config.CokeProcessing.CokeLeaf, trimming_scissors = 1}) - end - end -end) - -RegisterNetEvent('ps-drugprocessing:ProcessCocaPowder', function() - local coords = GetEntityCoords(PlayerPedId()) - local amount = 10 - local amount2 = 5 - - if #(coords-Config.CircleZones.CokePowder.coords) < 5 then - if not isProcessing then - local check = { - coke = Config.CokeProcessing.Coke, - bakingsoda = Config.CokeProcessing.BakingSoda, - finescale = 1 - } - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - CutCokePowder() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, check) - else - QBCore.Functions.Notify(Lang:t("error.already_processing"), 'error') - end - end -end) - -RegisterNetEvent('ps-drugprocessing:ProcessBricks', function() - local coords = GetEntityCoords(PlayerPedId(source)) - local amount = 4 - - if #(coords-Config.CircleZones.CokeBrick.coords) < 5 then - if not isProcessing then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessBricks() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {coke_small_brick = Config.CokeProcessing.SmallBrick, finescale = 1}) - else - QBCore.Functions.Notify(Lang:t("error.already_processing"), 'error') - end - end -end) +--- Plant Stuff -RegisterNetEvent('ps-drugprocessing:EnterCWarehouse', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - vector3(Config.CokeLab["enter"].coords.x, Config.CokeLab["enter"].coords.y, Config.CokeLab["enter"].coords.z)) - if dist < 2 then - if Config.KeyRequired then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - EnterCWarehouse() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, { cocainekey = 1 } ) - else - EnterCWarehouse() +CreateThread(function() + for k,v in pairs (GlobalState.psCoke) do + if not v.taken then + local model = GetHashKey(v.model) + ps.requestModel(model) + CocaPlants[k] = CreateObject(model, v.loc.x, v.loc.y, v.loc.z, false, true, false) + PlaceObjectOnGroundProperly(CocaPlants[k]) + FreezeEntityPosition(CocaPlants[k], true) + SetEntityAsMissionEntity(CocaPlants[k], true, true) + ps.entityTarget(CocaPlants[k], { + { + icon = "fas fa-seedling", + label = Lang:t("coke.pick_coca_leaf"), + action = function() + if not ps.progressbar('Picking Coca Leaf', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpCocaLeaf', k) + end, + }, + }) end end end) -RegisterNetEvent('ps-drugprocessing:ExitCWarehouse', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - vector3(Config.CokeLab["exit"].coords.x, Config.CokeLab["exit"].coords.y, Config.CokeLab["exit"].coords.z)) - if dist < 2 then - ExitCWarehouse() +RegisterNetEvent('ps-drugprocessing:removeCocaLeaf', function(location) + if CocaPlants[location] then + SetEntityAsMissionEntity(CocaPlants[location], false, true) + DeleteObject(CocaPlants[location]) end end) -RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local nearbyObject, nearbyID - - for i=1, #CocaPlants, 1 do - if #(coords - GetEntityCoords(CocaPlants[i])) < 2 then - nearbyObject, nearbyID = CocaPlants[i], i - end - end - - if nearbyObject and IsPedOnFoot(playerPed) then - if not isPickingUp then - isPickingUp = true - TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done - ClearPedTasks(playerPed) - SetEntityAsMissionEntity(nearbyObject, false, true) - DeleteObject(nearbyObject) - - table.remove(CocaPlants, nearbyID) - spawnedCocaLeaf = spawnedCocaLeaf - 1 - - TriggerServerEvent('ps-drugprocessing:pickedUpCocaLeaf') - isPickingUp = false - end, function() - ClearPedTasks(playerPed) - isPickingUp = false - end) - end - end - +RegisterNetEvent('ps-drugprocessing:addCocaLeaf', function(location) + local model = GetHashKey(GlobalState.psCoke[location].model) + ps.requestModel(model) + CocaPlants[location] = CreateObject(model, GlobalState.psCoke[location].loc.x, GlobalState.psCoke[location].loc.y, GlobalState.psCoke[location].loc.z, false, true, false) + PlaceObjectOnGroundProperly(CocaPlants[location]) + FreezeEntityPosition(CocaPlants[location], true) + SetEntityAsMissionEntity(CocaPlants[location], true, true) + ps.entityTarget(CocaPlants[location], { + { + icon = "fas fa-seedling", + label = Lang:t("coke.pick_coca_leaf"), + action = function() + if not ps.progressbar('Picking Coca Leaf', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpCocaLeaf', location) + end, + }, + }) end) AddEventHandler('onResourceStop', function(resource) @@ -349,29 +166,4 @@ AddEventHandler('onResourceStop', function(resource) DeleteObject(v) end end -end) - -RegisterCommand('propfix', function() - for _, v in pairs(GetGamePool('CObject')) do - if IsEntityAttachedToEntity(PlayerPedId(), v) then - SetEntityAsMissionEntity(v, true, true) - DeleteObject(v) - DeleteEntity(v) - end - end -end) - -CreateThread(function() - local cokeZone = CircleZone:Create(Config.CircleZones.CokeField.coords, 10.0, { - name = "ps-cokezone", - debugPoly = false - }) - cokeZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inCokeField = true - SpawnCocaPlants() - else - inCokeField = false - end - end) -end) +end) \ No newline at end of file diff --git a/client/heroin.lua b/client/heroin.lua index 4efb562..b46248b 100644 --- a/client/heroin.lua +++ b/client/heroin.lua @@ -1,174 +1,69 @@ -local spawnedPoppys = 0 -local PoppyPlants = {} -local isPickingUp, isProcessing, inHeroinField = false, false, false -local QBCore = exports['qb-core']:GetCoreObject() - -local function ValidateHeroinCoord(plantCoord) - local validate = true - if spawnedPoppys > 0 then - for _, v in pairs(PoppyPlants) do - if #(plantCoord - GetEntityCoords(v)) < 5 then - validate = false - end - end - if not inHeroinField then - validate = false - end - end - return validate -end - -local function GetCoordZHeroin(x, y) - local groundCheckHeights = { 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 50.0, 75.0, 100.0, 110.0, 125.0 } - - for i, height in ipairs(groundCheckHeights) do - local foundGround, z = GetGroundZFor_3dCoord(x, y, height) - - if foundGround then - return z - end - end - - return 12.64 -end -local function GenerateHeroinCoords() - while true do - Wait(1) - - local heroinCoordX, heroinCoordY - - math.randomseed(GetGameTimer()) - local modX = math.random(-60, 60) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY = math.random(-60, 60) - - heroinCoordX = Config.CircleZones.HeroinField.coords.x + modX - heroinCoordY = Config.CircleZones.HeroinField.coords.y + modY - - local coordZ = GetCoordZHeroin(heroinCoordX, heroinCoordY) - local coord = vector3(heroinCoordX, heroinCoordY, coordZ) - - if ValidateHeroinCoord(coord) then - return coord - end - end -end - -local function SpawnPoppyPlants() - local model = `prop_plant_01b` - while spawnedPoppys < 15 do - Wait(0) - local heroinCoords = GenerateHeroinCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) - end - local obj = CreateObject(model, heroinCoords.x, heroinCoords.y, heroinCoords.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(PoppyPlants, obj) - spawnedPoppys += 1 - end - SetModelAsNoLongerNeeded(model) -end - -local function ProcessHeroin() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processPoppyResin') - - local timeLeft = Config.Delays.HeroinProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 +local PoppyPlants = {} - if #(GetEntityCoords(playerPed)-Config.CircleZones.HeroinProcessing.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end +-- targets +ps.boxTarget("poppyProccess", vector3(1384.9, -2080.61, 52.21), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 180.0, +}, { + { + icon = "fas fa-envira", + label = Lang:t("target.heroinprocess"), + action = function() + if not ps.progressbar('Processing Poppies', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processPoppyResin') + end, + }, +}) +-- plant spawning -RegisterNetEvent('ps-drugprocessing:ProcessPoppy', function() - local coords = GetEntityCoords(PlayerPedId(source)) - - if #(coords-Config.CircleZones.HeroinProcessing.coords) < 5 then - if not isProcessing then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessHeroin() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {poppyresin = Config.HeroinProcessing.Poppy}) +CreateThread(function() + for k, v in pairs (GlobalState.psHeroin) do + if not v.taken then + local model = GetHashKey(v.model) + ps.requestModel(model) + PoppyPlants[k] = CreateObject(model, v.loc.x, v.loc.y, v.loc.z, false, true, false) + PlaceObjectOnGroundProperly(PoppyPlants[k]) + FreezeEntityPosition(PoppyPlants[k], true) + ps.entityTarget(PoppyPlants[k], { + { + icon = "fas fa-seedling", + label = Lang:t("heroin.pick_poppy"), + action = function() + if not ps.progressbar('Picking Poppy', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpPoppy', k) + end, + }, + }) end end end) -RegisterNetEvent("ps-drugprocessing:processHeroin",function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessHeroin() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {poppyresin = Config.HeroinProcessing.Poppy}) -end) - - -RegisterNetEvent("ps-drugprocessing:pickHeroin", function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local nearbyObject, nearbyID - - for i=1, #PoppyPlants, 1 do - if #(coords - GetEntityCoords(PoppyPlants[i])) < 2 then - nearbyObject, nearbyID = PoppyPlants[i], i - end +RegisterNetEvent('ps-drugprocessing:removePoppy', function(location) + if PoppyPlants[location] then + SetEntityAsMissionEntity(PoppyPlants[location], false, true) + DeleteObject(PoppyPlants[location]) end +end) - if nearbyObject and IsPedOnFoot(playerPed) then - isPickingUp = true - TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done - ClearPedTasks(playerPed) - SetEntityAsMissionEntity(nearbyObject, false, true) - DeleteObject(nearbyObject) - - table.remove(PoppyPlants, nearbyID) - spawnedPoppys -= 1 - - TriggerServerEvent('ps-drugprocessing:pickedUpPoppy') - isPickingUp = false - - end, function() - ClearPedTasks(playerPed) - isPickingUp = false - end) - end +RegisterNetEvent('ps-drugprocessing:addPoppy', function(location) + local model = GetHashKey(GlobalState.psHeroin[location].model) + ps.requestModel(model) + PoppyPlants[location] = CreateObject(model, GlobalState.psHeroin[location].loc.x, GlobalState.psHeroin[location].loc.y, GlobalState.psHeroin[location].loc.z, false, true, false) + PlaceObjectOnGroundProperly(PoppyPlants[location]) + FreezeEntityPosition(PoppyPlants[location], true) + ps.entityTarget(PoppyPlants[location], { + { + icon = "fas fa-seedling", + label = Lang:t("heroin.pick_poppy"), + action = function() + if not ps.progressbar('Picking Poppy', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpPoppy', location) + end, + }, + }) end) AddEventHandler('onResourceStop', function(resource) @@ -180,17 +75,3 @@ AddEventHandler('onResourceStop', function(resource) end end) -CreateThread(function() - local heroinZone = CircleZone:Create(Config.CircleZones.HeroinField.coords, 50.0, { - name = "ps-heroinzone", - debugPoly = false - }) - heroinZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inHeroinField = true - SpawnPoppyPlants() - else - inHeroinField = false - end - end) -end) diff --git a/client/hydrochloricacid.lua b/client/hydrochloricacid.lua index 979fbc3..e299fb8 100644 --- a/client/hydrochloricacid.lua +++ b/client/hydrochloricacid.lua @@ -1,138 +1,59 @@ -local spawnedHydrochloricAcidBarrels = 0 -local HydrochloricAcidBarrels = {} -local inhydrochloricField = false -local QBCore = exports['qb-core']:GetCoreObject() +local Chemicals = {} - -local function ValidateHydrochloricAcidCoord(plantCoord) - local validate = true - if spawnedHydrochloricAcidBarrels > 0 then - for _, v in pairs(HydrochloricAcidBarrels) do - if #(plantCoord-GetEntityCoords(v)) < 5 then - validate = false - end - end - if not inhydrochloricField then - validate = false - end - end - return validate -end - -local function GetCoordZHydrochloricAcid(x, y) - local groundCheckHeights = { 20.0, 21.0, 22.0, 23.0, 24.0, 175.0, 190.0, 200.0, 205.0, 215.0, 225.0 } - - for i, height in ipairs(groundCheckHeights) do - local found2Ground, z = GetGroundZFor_3dCoord(x, y, height) - - if found2Ground then - return z - end - end - - return 24.5 -end - -local function GenerateHydrochloricAcidCoords() - while true do - Wait(1) - - local weed2CoordX, weed2CoordY - - math.randomseed(GetGameTimer()) - local modX2 = math.random(-15, 15) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY2 = math.random(-15, 15) - - weed2CoordX = Config.CircleZones.HydrochloricAcidFarm.coords.x + modX2 - weed2CoordY = Config.CircleZones.HydrochloricAcidFarm.coords.y + modY2 - - local coordZ2 = GetCoordZHydrochloricAcid(weed2CoordX, weed2CoordY) - local coord2 = vector3(weed2CoordX, weed2CoordY, coordZ2) - - if ValidateHydrochloricAcidCoord(coord2) then - return coord2 +AddEventHandler('onResourceStop', function(resource) + if resource == GetCurrentResourceName() then + for _, v in pairs(Chemicals) do + SetEntityAsMissionEntity(v, false, true) + DeleteObject(v) end end -end +end) -local function SpawnHydrochloricAcidBarrels() - local model = `mw_hydro_barrel` - while spawnedHydrochloricAcidBarrels < 5 do - Wait(0) - local weedCoords = GenerateHydrochloricAcidCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) +local function spawnTargets() + for k, v in pairs (GlobalState.psHydro) do + if not v.taken then + local model = GetHashKey(v.model) + ps.requestModel(model) + Chemicals[k] = CreateObject(model, v.loc.x, v.loc.y, v.loc.z, false, true, false) + PlaceObjectOnGroundProperly(Chemicals[k]) + FreezeEntityPosition(Chemicals[k], true) + ps.entityTarget(Chemicals[k], { + { + icon = "fas fa-vials", + label = Lang:t("target.chemicals"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpHydrochloricAcid', k) + end, + }, + }) end - local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(HydrochloricAcidBarrels, obj) - spawnedHydrochloricAcidBarrels = spawnedHydrochloricAcidBarrels + 1 end - SetModelAsNoLongerNeeded(model) end -RegisterNetEvent("ps-drugprocessing:client:hydrochloricacid", function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local nearbyObject, nearbyID - - for i=1, #HydrochloricAcidBarrels, 1 do - if #(coords-GetEntityCoords(HydrochloricAcidBarrels[i])) < 2 then - nearbyObject, nearbyID = HydrochloricAcidBarrels[i], i - end - end - - if nearbyObject and IsPedOnFoot(playerPed) then - isPickingUp = true - TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - ClearPedTasks(playerPed) - SetEntityAsMissionEntity(nearbyObject, false, true) - DeleteObject(nearbyObject) +spawnTargets() - table.remove(HydrochloricAcidBarrels, nearbyID) - spawnedHydrochloricAcidBarrels -= 1 - - TriggerServerEvent('ps-drugprocessing:pickedUpHydrochloricAcid') - isPickingUp = false - end, function() - ClearPedTasks(playerPed) - isPickingUp = false - end) - end -end) - -AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - for _, v in pairs(HydrochloricAcidBarrels) do - SetEntityAsMissionEntity(v, false, true) - DeleteObject(v) - end +RegisterNetEvent('ps-drugprocessing:removeHydrochloricAcid', function(location) + if Chemicals[location] then + SetEntityAsMissionEntity(Chemicals[location], false, true) + DeleteObject(Chemicals[location]) end end) -CreateThread(function() - local hydrochloricZone = CircleZone:Create(Config.CircleZones.HydrochloricAcidFarm.coords, 50.0, { - name = "ps-hydrochloriczone", - debugPoly = false +RegisterNetEvent('ps-drugprocessing:addHydrochloricAcid', function(location) + local model = GetHashKey(GlobalState.psHydro[location].model) + ps.requestModel(model) + Chemicals[location] = CreateObject(model, GlobalState.psHydro[location].loc.x, GlobalState.psHydro[location].loc.y, GlobalState.psHydro[location].loc.z, false, true, false) + PlaceObjectOnGroundProperly(Chemicals[location]) + FreezeEntityPosition(Chemicals[location], true) + ps.entityTarget(Chemicals[location], { + { + icon = "fas fa-vials", + label = Lang:t("target.chemicals"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpHydrochloricAcid', location) + end, + }, }) - hydrochloricZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inhydrochloricField = true - SpawnHydrochloricAcidBarrels() - else - inhydrochloricField = false - end - end) -end) +end) \ No newline at end of file diff --git a/client/lsd.lua b/client/lsd.lua index 41424e6..4da6366 100644 --- a/client/lsd.lua +++ b/client/lsd.lua @@ -1,107 +1,31 @@ -local isPickingUp, isProcessing = false, false -local QBCore = exports['qb-core']:GetCoreObject() -local function Processlsd() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - disableKeyboard = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:Processlsd') - - local timeLeft = Config.Delays.lsdProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.lsdProcessing.coords) > 5 then - QBCore.Functions.Notify(Lang:t("error.too_far")) - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -local function Processthionylchloride() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - disableKeyboard = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processThionylChloride') - local timeLeft = Config.Delays.thionylchlorideProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.thionylchlorideProcessing.coords) > 5 then - QBCore.Functions.Notify(Lang:t("error.too_far")) - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -CreateThread(function() - while true do - Wait(0) - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - - if #(coords-Config.CircleZones.lsdProcessing.coords) < 2 then - if not isProcessing then - local pos = GetEntityCoords(PlayerPedId()) - QBCore.Functions.DrawText3D(pos.x, pos.y, pos.z, Lang:t("drawtext.process_lsd")) - end - if IsControlJustReleased(0, 38) and not isProcessing then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - Processlsd() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {lsa = 1, thionyl_chloride = 1}) - end - else - Wait(500) - end - end -end) - -RegisterNetEvent('ps-drugprocessing:processingThiChlo', function() - local coords = GetEntityCoords(PlayerPedId(source)) - - if #(coords-Config.CircleZones.thionylchlorideProcessing.coords) < 5 then - if not isProcessing then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - Processthionylchloride() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {lsa = 1, chemicals = 1}) - end - end -end) +ps.boxTarget('thychloride',vector3(-679.77, 5800.7, 17.33), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 340.0, +}, { + { + icon = "fas fa-biohazard", + label = Lang:t("target.process_thionyl_chloride"), + action = function() + if not ps.progressbar('Processing Thionyl Chloride', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processThionylChloride') + end, + }, +}) +ps.boxTarget('lsdprocess', vector3(2503.53, -427.48, 92.99), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 340.0, +}, { + { + icon = "fas fa-biohazard", + label = Lang:t("target.process_lsd"), + action = function() + if not ps.progressbar('Processing LSD', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:Processlsd') + end, + }, +}) \ No newline at end of file diff --git a/client/meth.lua b/client/meth.lua index 56c2c04..759919a 100644 --- a/client/meth.lua +++ b/client/meth.lua @@ -1,150 +1,7 @@ -local isProcessing, isTempChangeU, isTempChangeD, isBagging = false, false, false, false -local Methlab = false -local QBCore = exports['qb-core']:GetCoreObject() - -local function ProcessChemicals() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processChemicals') - - local timeLeft = Config.Delays.MethProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.MethProcessing.coords) > 2 then - QBCore.Functions.Notify(Lang:t("error.too_far"), "error") - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end - -local function ProcessTempUp() - isTempChangeU = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.temp_up"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processTempUp') - - local timeLeft = Config.Delays.MethProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.MethTemp.coords) > 2 then - QBCore.Functions.Notify(Lang:t("error.too_far"), "error") - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isTempChangeU = false - end, function() - ClearPedTasks(playerPed) - isTempChangeU = false - end) -end - -local function ProcessTempDown() - isTempChangeD = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.temp_down"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processTempDown') - - local timeLeft = Config.Delays.MethProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.MethTemp.coords) > 2 then - QBCore.Functions.Notify(Lang:t("error.too_far"), "error") - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isTempChangeD = false - end, function() - ClearPedTasks(playerPed) - isTempChangeD = false - end) -end - -local function ProcessProduct() - isBagging = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.packing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processMeth') - - local timeLeft = Config.Delays.MethProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.MethBag.coords) > 2 then - QBCore.Functions.Notify(Lang:t("error.too_far"), "error") - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isBagging = false - end, function() - ClearPedTasks(playerPed) - isBagging = false - end) -end - -local function LoadAnimationDict(dict) - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - RequestAnimDict(dict) - Wait(1) - end -end - -local function OpenDoorAnimation() - local ped = PlayerPedId() - LoadAnimationDict("anim@heists@keycard@") - TaskPlayAnim(ped, "anim@heists@keycard@", "exit", 5.0, 1.0, -1, 16, 0, 0, 0, 0) - Wait(400) - ClearPedTasks(ped) -end local function EnterMethlab() local ped = PlayerPedId() - OpenDoorAnimation() + ps.playEmote('openDoor') Methlab = true Wait(500) DoScreenFadeOut(250) @@ -157,16 +14,8 @@ end local function ExitMethlab() local ped = PlayerPedId() - local dict = "mp_heists@keypad@" - local keypad = {coords = {x = 969.04, y = -146.17, z = -46.4, h = 94.5, r = 1.0}} - SetEntityCoords(ped, keypad.coords.x, keypad.coords.y, keypad.coords.z - 0.98) - SetEntityHeading(ped, keypad.coords.h) - Methlab = true - LoadAnimationDict(dict) - TaskPlayAnim(ped, "mp_heists@keypad@", "idle_a", 8.0, 8.0, -1, 0, 0, false, false, false) - Wait(2500) - TaskPlayAnim(ped, "mp_heists@keypad@", "exit", 2.0, 2.0, -1, 0, 0, false, false, false) - Wait(1000) + ps.playEmote('openDoor') + Wait(500) DoScreenFadeOut(250) Wait(250) SetEntityCoords(ped, Config.MethLab["enter"].coords.x, Config.MethLab["enter"].coords.y, Config.MethLab["enter"].coords.z - 0.98) @@ -176,113 +25,113 @@ local function ExitMethlab() DoScreenFadeIn(250) end -RegisterNetEvent('ps-drugprocessing:ProcessChemicals', function() - local coords = GetEntityCoords(PlayerPedId(source)) - - if #(coords-Config.CircleZones.MethProcessing.coords) < 5 then - if not isProcessing then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessChemicals() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {sulfuric_acid = Config.MethProcessing.SulfAcid, hydrochloric_acid = Config.MethProcessing.HydAcid, sodium_hydroxide = Config.MethProcessing.SodHyd}) - else - QBCore.Functions.Notify(Lang:t("error.already_processing"), 'error') - end - end -end) - -RegisterNetEvent('ps-drugprocessing:ChangeTemp', function() - if not isTempChangeU then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - exports['ps-ui']:Thermite(function(success) - if success then - QBCore.Functions.Notify(Lang:t("success.temp_up"), 'success') - ProcessTempUp() - else - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - TriggerServerEvent('ps-drugprocessing:processFailUp') - end - end, 10, 5, 3) - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) +ps.boxTarget('processChemicals', vector3(978.22, -147.1, -48.53), { + length = 1.2, + width = 0.5, + height = 0.5, + rotation = 354.0, +}, { + { + icon = "fas fa-temperature-full", + label = Lang:t("target.methtempup"), + action = function() + if not ps.progressbar(Lang:t("progressbar.mixing"), 15000, 'uncuff') then return end + TriggerEvent('ps-drugprocessing:processChemicals') + end, + }, +}) + +ps.boxTarget('ChangeTempUp', vector3(982.56, -145.59, -49.0), { + length = 1.2, + width = 0.5, + height = 0.5, + rotation = 354.0, +}, { + { + icon = "fas fa-temperature-full", + label = Lang:t("target.methtempup"), + action = function() + if not ps.minigame('ps-circle', {amount = 2, speed = 4}) then + TriggerServerEvent('ps-drugprocessing:processFailUp') + return end - end, {liquidmix = 1}) - else - QBCore.Functions.Notify(Lang:t("error.enough_temp"), 'error') - end -end) - -RegisterNetEvent('ps-drugprocessing:ChangeTemp2', function() - if not isTempChangeD then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - exports['ps-ui']:Thermite(function(success) - if success then - QBCore.Functions.Notify(Lang:t("success.temp_down"), 'success') - ProcessTempDown() - else - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - TriggerServerEvent('ps-drugprocessing:processFailDown') - end - end, 10, 5, 3) - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) + if not ps.progressbar(Lang:t("progressbar.temp_up"), 15000, 'uncuff') then return end + TriggerEvent('ps-drugprocessing:processTempUp') + end, + }, +}) +ps.boxTarget('ChangeTempDown', vector3(979.59, -144.14, -49.0), { + length = 1.2, + width = 0.5, + height = 0.5, + rotation = 354.0, +}, { + { + icon = "fas fa-temperature-empty", + label = Lang:t("target.methtempdown"), + action = function() + if not ps.minigame('ps-circle', {amount = 2, speed = 4}) then + TriggerServerEvent('ps-drugprocessing:processFailDown') + return end - end, {chemicalvapor = 1}) - else - QBCore.Functions.Notify(Lang:t("error.enough_temp"), 'error') - end -end) - - -RegisterNetEvent('ps-drugprocessing:ProcessProduct', function() - local coords = GetEntityCoords(PlayerPedId(source)) - - if #(coords-Config.CircleZones.MethBag.coords) < 5 then - if not isBagging then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessProduct() + if not ps.progressbar(Lang:t("progressbar.temp_down"), 15000, 'uncuff') then return end + TriggerEvent('ps-drugprocessing:processTempDown') + end, + }, +}) + +ps.boxTarget('methProcess', vector3(987.44, -140.5, -49.0), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 180.0, +}, { + { + icon = "fas fa-envira", + label = Lang:t("target.methprocess"), + action = function() + if not ps.progressbar(Lang:t("progressbar.packing"), 15000, 'uncuff') then return end + TriggerEvent('ps-drugprocessing:ProcessProduct') + end, + }, +}) + +ps.boxTarget('exitMeth', vector3(969.04, -146.17, -46.4), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 180.0, +}, { + { + icon = "fas fa-box", + label = Lang:t("target.heroinprocess"), + action = function() + ExitMethlab() + end, + }, +}) + +CreateThread(function() + local model = 'a_m_m_hillbilly_02' + ps.requestModel(model) + local ped = CreatePed(0, model, vector4(-1187.73, -445.27, 43.91, 289.45), false, true) + SetBlockingOfNonTemporaryEvents(ped, true) + SetEntityInvincible(ped, true) + FreezeEntityPosition(ped, true) + ps.entityTarget(ped, { + { + icon = "fas fa-atom", + label = Lang:t("target.talk_to_walter"), + action = function() + EnterMethlab() + end, + canInteract = function() + if Config.KeyRequired then + return ps.hasKey('methkey') else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) + return true end - end, {methtray=1}) - else - QBCore.Functions.Notify(Lang:t("error.already_processing"), 'error') - end - end -end) - -RegisterNetEvent('ps-drugprocessing:EnterLab', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - vector3(Config.MethLab["enter"].coords.x, Config.MethLab["enter"].coords.y, Config.MethLab["enter"].coords.z)) - if dist < 2 then - if not Methlab then - if Config.KeyRequired then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - EnterMethlab() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, { methkey = 1 } ) - else - EnterMethlab() - end - end - end -end) - -RegisterNetEvent('ps-drugprocessing:ExitLab', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - vector3(Config.MethLab["exit"].coords.x, Config.MethLab["exit"].coords.y, Config.MethLab["exit"].coords.z)) - if dist < 2 then - ExitMethlab() - end -end) + end, + } + }) +end) \ No newline at end of file diff --git a/client/sodiumhydroxide.lua b/client/sodiumhydroxide.lua index 423bfe6..e89cef2 100644 --- a/client/sodiumhydroxide.lua +++ b/client/sodiumhydroxide.lua @@ -1,140 +1,60 @@ -local spawnedSodiumHydroxideBarrels = 0 + local SodiumHydroxideBarrels = {} -local inSodiumFarm = false -local QBCore = exports['qb-core']:GetCoreObject() -local function ValidateSodiumHydroxideCoord(plantCoord) - local validate2 = true - if spawnedSodiumHydroxideBarrels > 0 then +AddEventHandler('onResourceStop', function(resource) + if resource == GetCurrentResourceName() then for _, v in pairs(SodiumHydroxideBarrels) do - if #(plantCoord - GetEntityCoords(v)) < 5 then - validate2 = false - end - end - if not inSodiumFarm then - validate = false - end - end - return validate2 -end - -local function GetCoordZSodiumHydroxide(x, y) - local groundCheckHeights = { 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 300.0 } - - for i, height in ipairs(groundCheckHeights) do - local found3Ground, z = GetGroundZFor_3dCoord(x, y, height) - - if found3Ground then - return z - end - end - - return 100.0 -end - -local function GenerateSodiumHydroxideCoords() - while true do - Wait(1) - - local weed3CoordX, weed3CoordY - - math.randomseed(GetGameTimer()) - local modX3 = math.random(-7, 7) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY3 = math.random(-7, 7) - - weed3CoordX = Config.CircleZones.SodiumHydroxideFarm.coords.x + modX3 - weed3CoordY = Config.CircleZones.SodiumHydroxideFarm.coords.y + modY3 - - local coordZ3 = GetCoordZSodiumHydroxide(weed3CoordX, weed3CoordY) - local coord3 = vector3(weed3CoordX, weed3CoordY, coordZ3) - - if ValidateSodiumHydroxideCoord(coord3) then - return coord3 + SetEntityAsMissionEntity(v, false, true) + DeleteObject(v) end end -end +end) -local function SpawnSodiumHydroxideBarrels() - local model = `mw_sodium_barrel` - while spawnedSodiumHydroxideBarrels < 10 do - Wait(0) - local weedCoords2 = GenerateSodiumHydroxideCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) +local function spawnTargets() + for k, v in pairs (GlobalState.psSodium) do + if not v.taken then + SodiumHydroxideBarrels[k] = CreateObjectNoOffset(GetHashKey(v.model), v.loc.x, v.loc.y, v.loc.z, false, false, false) + SetEntityHeading(SodiumHydroxideBarrels[k], v.heading) + SetEntityAsMissionEntity(SodiumHydroxideBarrels[k], true, true) + FreezeEntityPosition(SodiumHydroxideBarrels[k], true) + ps.entityTarget(SodiumHydroxideBarrels[k], { + { + icon = "fas fa-vials", + label = Lang:t("target.sodium_hydroxide"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpSodiumHydroxide', k) + end, + }, + }) end - local obj = CreateObject(model, weedCoords2.x, weedCoords2.y, weedCoords2.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(SodiumHydroxideBarrels, obj) - spawnedSodiumHydroxideBarrels = spawnedSodiumHydroxideBarrels + 1 end - SetModelAsNoLongerNeeded(model) end +spawnTargets() -RegisterNetEvent("ps-drugprocessing:pickSodium", function() - local playerPe3 = PlayerPedId() - local coords = GetEntityCoords(playerPe3) - local nearbyObject3, nearbyID3 - - for i=1, #SodiumHydroxideBarrels, 1 do - if #(coords - GetEntityCoords(SodiumHydroxideBarrels[i])) < 2 then - nearbyObject3, nearbyID3 = SodiumHydroxideBarrels[i], i - end - end - - if nearbyObject3 and IsPedOnFoot(playerPe3) then - if not isPickingUp then - isPickingUp = true - TaskStartScenarioInPlace(playerPe3, 'world_human_gardener_plant', 0, false) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - ClearPedTasks(PlayerPedId()) - SetEntityAsMissionEntity(nearbyObject3, false, true) - DeleteObject(nearbyObject3) - - table.remove(SodiumHydroxideBarrels, nearbyID3) - spawnedSodiumHydroxideBarrels -= 1 - - TriggerServerEvent('ps-drugprocessing:pickedUpSodiumHydroxide') - isPickingUp = false - end, function() - ClearPedTasks(PlayerPedId()) - isPickingUp = false - end) - end - end -end) - -AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - for _, v in pairs(SodiumHydroxideBarrels) do - SetEntityAsMissionEntity(v, false, true) - DeleteObject(v) - end +RegisterNetEvent('ps-drugprocessing:removeSodiumHydroxide', function(location) + if SodiumHydroxideBarrels[location] then + SetEntityAsMissionEntity(SodiumHydroxideBarrels[location], false, true) + DeleteObject(SodiumHydroxideBarrels[location]) end end) -CreateThread(function() - local sodiumZone = CircleZone:Create(Config.CircleZones.SodiumHydroxideFarm.coords, 50.0, { - name = "ps-sodiumzone", - debugPoly = false +RegisterNetEvent('ps-drugprocessing:addSodiumHydroxide', function(location) + local model = GetHashKey(GlobalState.psSodium[location].model) + ps.requestModel(model) + SodiumHydroxideBarrels[location] = CreateObjectNoOffset(model, GlobalState.psSodium[location].loc.x, GlobalState.psSodium[location].loc.y, GlobalState.psSodium[location].loc.z, false, false, false) + SetEntityHeading(SodiumHydroxideBarrels[location], GlobalState.psSodium[location].heading) + SetEntityAsMissionEntity(SodiumHydroxideBarrels[location], true, true) + FreezeEntityPosition(SodiumHydroxideBarrels[location], true) + ps.entityTarget(SodiumHydroxideBarrels[location], { + { + icon = "fas fa-vials", + label = Lang:t("target.sodium_hydroxide"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpSodiumHydroxide', location) + end, + }, }) - sodiumZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inSodiumFarm = true - SpawnSodiumHydroxideBarrels() - else - inSodiumFarm = false - end - end) end) diff --git a/client/sulfuricacid.lua b/client/sulfuricacid.lua index 0eb8723..1e86925 100644 --- a/client/sulfuricacid.lua +++ b/client/sulfuricacid.lua @@ -1,138 +1,61 @@ -local spawnedSulfuricAcidBarrels = 0 -local SulfuricAcidBarrels = {} -local inSulfuricFarm = false -local QBCore = exports['qb-core']:GetCoreObject() -local function ValidateSulfuricAcidCoord(plantCoord) - local validate = true - if spawnedSulfuricAcidBarrels > 0 then - for _, v in pairs(SulfuricAcidBarrels) do - if #(plantCoord - GetEntityCoords(v)) < 5 then - validate = false - end - end - if not inSulfuricFarm then - validate2 = false - end - end - return validate -end - -local function GetCoordZSulfuricAcid(x, y) - local groundCheckHeights = { 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 150.0 } - - for i, height in ipairs(groundCheckHeights) do - local foundGround, z = GetGroundZFor_3dCoord(x, y, height) - - if foundGround then - return z - end - end - - return 18.31 -end - -local function GenerateSulfuricAcidCoords() - while true do - Wait(1) - - local weedCoordX, weedCoordY - - math.randomseed(GetGameTimer()) - local modX = math.random(-7, 7) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY = math.random(-7, 7) - - weedCoordX = Config.CircleZones.SulfuricAcidFarm.coords.x + modX - weedCoordY = Config.CircleZones.SulfuricAcidFarm.coords.y + modY +local SulfuricAcidBarrels = {} - local coordZ = GetCoordZSulfuricAcid(weedCoordX, weedCoordY) - local coord = vector3(weedCoordX, weedCoordY, coordZ) - if ValidateSulfuricAcidCoord(coord) then - return coord +AddEventHandler('onResourceStop', function(resource) + if resource == GetCurrentResourceName() then + for _, v in pairs(SulfuricAcidBarrels) do + SetEntityAsMissionEntity(v, false, true) + DeleteObject(v) end end -end +end) -local function SpawnSulfuricAcidBarrels() - local model = `mw_sulfuric_barrel` - while spawnedSulfuricAcidBarrels < 10 do - Wait(0) - local weedCoords = GenerateSulfuricAcidCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) +local function spawnTargets() + for k, v in pairs(GlobalState.psSulfuric) do + if not v.taken then + SulfuricAcidBarrels[k] = CreateObjectNoOffset(GetHashKey(v.model), v.loc.x, v.loc.y, v.loc.z, false, false, false) + SetEntityHeading(SulfuricAcidBarrels[k], v.heading) + SetEntityAsMissionEntity(SulfuricAcidBarrels[k], true, true) + FreezeEntityPosition(SulfuricAcidBarrels[k], true) + ps.entityTarget(SulfuricAcidBarrels[k], { + { + icon = "fas fa-vials", + label = Lang:t("target.sulfuric_acid"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpSulfuricAcid', k) + end, + }, + }) end - local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(SulfuricAcidBarrels, obj) - spawnedSulfuricAcidBarrels += 1 end - SetModelAsNoLongerNeeded(model) end +spawnTargets() -RegisterNetEvent("ps-drugprocessing:pickSulfuric", function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local nearbyObject, nearbyID - - for i=1, #SulfuricAcidBarrels, 1 do - if #(coords - GetEntityCoords(SulfuricAcidBarrels[i])) < 2 then - nearbyObject, nearbyID = SulfuricAcidBarrels[i], i - end - end - - if nearbyObject and IsPedOnFoot(playerPed) then - if not isPickingUp then - isPickingUp = true - TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done - ClearPedTasks(PlayerPedId()) - SetEntityAsMissionEntity(nearbyObject, false, true) - DeleteObject(nearbyObject) - table.remove(SulfuricAcidBarrels, nearbyID) - spawnedSulfuricAcidBarrels -= 1 - TriggerServerEvent('ps-drugprocessing:pickedUpSulfuricAcid') - isPickingUp = false - end, function() - ClearPedTasks(PlayerPedId()) - isPickingUp = false - end) - end +RegisterNetEvent('ps-drugprocessing:removeSulfuricAcid', function(location) + if SulfuricAcidBarrels[location] then + SetEntityAsMissionEntity(SulfuricAcidBarrels[location], false, true) + DeleteObject(SulfuricAcidBarrels[location]) end end) -AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - for _, v in pairs(SulfuricAcidBarrels) do - SetEntityAsMissionEntity(v, false, true) - DeleteObject(v) - end - end -end) - -CreateThread(function() - local sulfuricZone = CircleZone:Create(Config.CircleZones.SulfuricAcidFarm.coords, 50.0, { - name = "ps-sulfuriczone", - debugPoly = false +RegisterNetEvent('ps-drugprocessing:addSulfuricAcid', function(location) + local model = GetHashKey(GlobalState.psSulfuric[location].model) + ps.requestModel(model) + SulfuricAcidBarrels[location] = CreateObjectNoOffset(model, GlobalState.psSulfuric[location].loc.x, GlobalState.psSulfuric[location].loc.y, GlobalState.psSulfuric[location].loc.z, false, false, false) + SetEntityHeading(SulfuricAcidBarrels[location], GlobalState.psSulfuric[location].heading) + SetEntityAsMissionEntity(SulfuricAcidBarrels[location], true, true) + FreezeEntityPosition(SulfuricAcidBarrels[location], true) + ps.entityTarget(SulfuricAcidBarrels[location], { + { + icon = "fas fa-vials", + label = Lang:t("target.sulfuric_acid"), + action = function() + if not ps.progressbar(Lang:t("progressbar.processing"), 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpSulfuricAcid', location) + end, + }, }) - sulfuricZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inSulfuricFarm = true - SpawnSulfuricAcidBarrels() - else - inSulfuricFarm = false - end - end) -end) +end) \ No newline at end of file diff --git a/client/target.lua b/client/target.lua index 5027143..41ca253 100644 --- a/client/target.lua +++ b/client/target.lua @@ -1,63 +1,70 @@ local QBCore = exports['qb-core']:GetCoreObject() CreateThread(function() - exports['qb-target']:SpawnPed({ - model = 'a_m_m_hillbilly_02', - coords = vector4(-1187.73, -445.27, 43.91, 289.45), - minusOne = true, - freeze = true, - invincible = true, - blockevents = true, - target = { - options = { - { - type = "client", - event = "ps-drugprocessing:EnterLab", - icon = "fas fa-atom", - label = Lang:t("target.talk_to_walter"), - } - }, - distance = 2.5, - }, - }) - exports['qb-target']:SpawnPed({ - model = 'a_m_m_mlcrisis_01', - coords = vector4(812.49, -2399.59, 23.66, 223.1), - minusOne = true, - freeze = true, - invincible = true, - blockevents = true, - target = { - options = { - { - type = "client", - event = "ps-drugprocessing:EnterCWarehouse", - icon = "fas fa-key", - label = Lang:t("target.talk_to_draco"), - } - }, - distance = 2.5, - }, - }) - exports['qb-target']:SpawnPed({ - model = 'mp_f_weed_01', - coords = vector4(102.07, 175.08, 104.59, 159.91), - minusOne = true, - freeze = true, - invincible = true, - blockevents = true, - target = { - options = { - { - type = "client", - event = "ps-drugprocessing:EnterWWarehouse", - icon = "fas fa-key", - label = Lang:t("target.talk_to_charlotte"), - } - }, - distance = 2.5, - }, - }) + local peds = {'a_m_m_hillbilly_02','a_m_m_mlcrisis_01','mp_f_weed_01',} + for k, v in pairs ( peds) do + RequestModel(v) + while not HasModelLoaded(v) do + Wait(100) + end + end + local walterloc = vector4(-1187.73, -445.27, 43.91-1, 289.45) + local walter = CreatePed(0, 'a_m_m_hillbilly_02',walterloc.x, walterloc.y, walterloc.z, walterloc.w, false, false) + FreezeEntityPosition(walter, true) + SetEntityInvincible(walter, true) + SetBlockingOfNonTemporaryEvents(walter, true) + local options = { + { + type = "client", + event = "ps-drugprocessing:EnterLab", + icon = "fas fa-atom", + distance = 2.0, + label = Lang:t("target.talk_to_walter"), + } + } + if Config.OxTarget then + exports.ox_target:addLocalEntity(walter, options) + else + exports['qb-target']:AddTargetEntity(walter, { options = options, distance = 2.0}) + end + local dracoloc = vector4(812.49, -2399.59, 23.66-1, 223.1) + local draco = CreatePed(0, 'a_m_m_mlcrisis_01',dracoloc.x, dracoloc.y, dracoloc.z, dracoloc.w, false, false) + FreezeEntityPosition(draco, true) + SetEntityInvincible(draco, true) + SetBlockingOfNonTemporaryEvents(draco, true) + local options2 = { + { + type = "client", + event = "ps-drugprocessing:EnterCWarehouse", + icon = "fas fa-key", + label = Lang:t("target.talk_to_draco"), + distance = 2.0, + } + } + if Config.OxTarget then + exports.ox_target:addLocalEntity(draco, options2) + else + exports['qb-target']:AddTargetEntity(draco, { options = options2, distance = 2.0}) + end + local charlotteloc = vector4(102.07, 175.08, 104.59-1, 159.91) + local charlotte = CreatePed(0, 'mp_f_weed_01',charlotteloc.x, charlotteloc.y, charlotteloc.z, charlotteloc.w, false, false) + FreezeEntityPosition(charlotte, true) + SetEntityInvincible(charlotte, true) + SetBlockingOfNonTemporaryEvents(charlotte, true) + local options3 = { + { + type = "client", + event = "ps-drugprocessing:EnterWWarehouse", + icon = "fas fa-key", + label = Lang:t("target.talk_to_charlotte"), + distance = 2.0, + } + } + if Config.OxTarget then + exports.ox_target:addLocalEntity(charlotte, options3) + else + exports['qb-target']:AddTargetEntity(charlotte, { options = options3, distance = 2.0}) + end end) CreateThread(function() diff --git a/client/weed.lua b/client/weed.lua index 21f5ee4..7887829 100644 --- a/client/weed.lua +++ b/client/weed.lua @@ -1,27 +1,10 @@ -local spawnedWeeds = 0 -local weedPlants = {} -local isPickingUp, isProcessing, inWeedField = false, false, false -local QBCore = exports['qb-core']:GetCoreObject() - -local function LoadAnimationDict(dict) - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - RequestAnimDict(dict) - Wait(1) - end -end -local function OpenDoorAnimation() - local ped = PlayerPedId() - LoadAnimationDict("anim@heists@keycard@") - TaskPlayAnim(ped, "anim@heists@keycard@", "exit", 5.0, 1.0, -1, 16, 0, 0, 0, 0) - Wait(400) - ClearPedTasks(ped) -end +local weedPlants = {} +-- Lab Stuffs local function EnterWWarehouse() local ped = PlayerPedId() - OpenDoorAnimation() + ps.playEmote('openDoor') WWarehouse = true Wait(500) DoScreenFadeOut(250) @@ -34,7 +17,7 @@ end local function ExitWWarehouse() local ped = PlayerPedId() - OpenDoorAnimation() + ps.playEmote('openDoor') WWarehouse = true Wait(500) DoScreenFadeOut(250) @@ -46,230 +29,124 @@ local function ExitWWarehouse() WWarehouse = false end -local function ValidateWeedCoord(plantCoord) - local validate = true - if spawnedWeeds > 0 then - for _, v in pairs(weedPlants) do - if #(plantCoord - GetEntityCoords(v)) < 5 then - validate = false - end - end - if not inWeedField then - validate = false - end - end - return validate -end - -local function GetCoordZWeed(x, y) - local groundCheckHeights = { 50, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0 } - - for i, height in ipairs(groundCheckHeights) do - local foundGround, z = GetGroundZFor_3dCoord(x, y, height) - - if foundGround then - return z - end - end - - return 53.85 -end - -local function GenerateWeedCoords() - while true do - Wait(1) - - local weedCoordX, weedCoordY - - math.randomseed(GetGameTimer()) - local modX = math.random(-20, 20) - - Wait(100) - - math.randomseed(GetGameTimer()) - local modY = math.random(-20, 20) - - weedCoordX = Config.CircleZones.WeedField.coords.x + modX - weedCoordY = Config.CircleZones.WeedField.coords.y + modY - - local coordZ = GetCoordZWeed(weedCoordX, weedCoordY) - local coord = vector3(weedCoordX, weedCoordY, coordZ) - - if ValidateWeedCoord(coord) then - return coord - end - end -end - -local function SpawnWeedPlants() - local model = `mw_weed_plant` - while spawnedWeeds < 15 do - Wait(0) - local weedCoords = GenerateWeedCoords() - RequestModel(model) - while not HasModelLoaded(model) do - Wait(100) - end - local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false) - PlaceObjectOnGroundProperly(obj) - FreezeEntityPosition(obj, true) - table.insert(weedPlants, obj) - spawnedWeeds += 1 - end - SetModelAsNoLongerNeeded(model) -end - -local function RollJoint() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.rolling_joint"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:rollJoint') - local timeLeft = Config.Delays.WeedProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - end - ClearPedTasks(PlayerPedId()) - isProcessing = false - end, function() - ClearPedTasks(PlayerPedId()) - isProcessing = false - end) -end - -local function BagSkunk() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.bagging_skunk"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:bagskunk') - local timeLeft = Config.Delays.WeedProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - end - ClearPedTasks(PlayerPedId()) - isProcessing = false - end, function() - ClearPedTasks(PlayerPedId()) - isProcessing = false - end) +ps.boxTarget("weedexit", vector3(1066.51, -3183.44, -39.16), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 180.0, +}, { + { + icon = "fas fa-lock", + label = Lang:t("target.keypad"), + action = function() + ExitWWarehouse() + end, + }, +}) + +ps.boxTarget("weedproces", vector3(1038.37, -3206.06, -38.17), { + length = 1.0, + width = 1.0, + height = 1.0, + rotation = 165.63, +}, { + { + icon = "fas fa-envira", + label = Lang:t("target.weedproces"), + action = function() + if not ps.progressbar('Processing Weed', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:processCannabis') + end, + }, +}) + +local function spawnWeedPed() + ps.requestModel("mp_f_weed_01") + local weedPed = CreatePed(4, GetHashKey("mp_f_weed_01"),vector4(102.07, 175.08, 104.59 -1, 159.91), false, true) + SetBlockingOfNonTemporaryEvents(weedPed, true) + SetEntityInvincible(weedPed, true) + FreezeEntityPosition(weedPed, true) + ps.entityTarget(weedPed, { + { + icon = "fas fa-lock", + label = Lang:t("target.talk_to_charlotte"), + action = function() + EnterWWarehouse() + end, + canInteract = function() + if Config.KeyRequired then + return ps.hasItem('weedkey') + else + return true + end + end, + }, + }) end +spawnWeedPed() -local function ProcessWeed() - isProcessing = true - local playerPed = PlayerPedId() - - TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.processing"), 15000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() - TriggerServerEvent('ps-drugprocessing:processCannabis') - local timeLeft = Config.Delays.WeedProcessing / 1000 - while timeLeft > 0 do - Wait(1000) - timeLeft -= 1 - if #(GetEntityCoords(playerPed)-Config.CircleZones.WeedProcessing.coords) > 4 then - TriggerServerEvent('ps-drugprocessing:cancelProcessing') - break - end - end - ClearPedTasks(playerPed) - isProcessing = false - end, function() - ClearPedTasks(playerPed) - isProcessing = false - end) -end +-- useable Item Triggers +RegisterNetEvent('ps-drugprocessing:client:rollJoint', function() + if not ps.progressbar('Rolling Joint', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:rollJoint') +end) -RegisterNetEvent("ps-drugprocessing:processWeed",function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - ProcessWeed() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end,{cannabis = 1}) +RegisterNetEvent('ps-drugprocessing:client:bagskunk', function() + if not ps.progressbar('Bagging Skunk', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:bagskunk') end) -RegisterNetEvent('ps-drugprocessing:EnterWWarehouse', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - vector3(Config.WeedLab["enter"].coords.x, Config.WeedLab["enter"].coords.y, Config.WeedLab["enter"].coords.z)) - if dist < 2 then - if Config.KeyRequired then - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - EnterWWarehouse() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {weedkey=1}) - else - EnterWWarehouse() + +-- Weed Plant Spawning +CreateThread(function() + for k, v in pairs(GlobalState.psWeed) do + if not v.taken then + local model = GetHashKey(v.model) + ps.requestModel(model) + weedPlants[k] = CreateObject(model, v.loc.x, v.loc.y, v.loc.z, false, true, false) + PlaceObjectOnGroundProperly(weedPlants[k]) + FreezeEntityPosition(weedPlants[k], true) + ps.entityTarget(weedPlants[k], { + { + icon = "fas fa-seedling", + label = Lang:t("weed.pick_weed"), + action = function() + if weedPlants[k] then + if not ps.progressbar('Picking Weed', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpCannabis', k) + end + end, + }, + }) end end end) -RegisterNetEvent('ps-drugprocessing:ExitWWarehouse', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - vector3(Config.WeedLab["exit"].coords.x, Config.WeedLab["exit"].coords.y, Config.WeedLab["exit"].coords.z)) - if dist < 2 then - ExitWWarehouse() +RegisterNetEvent('ps-drugprocessing:removeWeed', function(location) + if weedPlants[location] then + SetEntityAsMissionEntity(weedPlants[location], false, true) + DeleteObject(weedPlants[location]) end end) -RegisterNetEvent("ps-drugprocessing:pickWeed", function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local nearbyObject, nearbyID - - for i=1, #weedPlants, 1 do - if #(coords - GetEntityCoords(weedPlants[i])) < 2 then - nearbyObject, nearbyID = weedPlants[i], i - end - end - - if nearbyObject and IsPedOnFoot(playerPed) then - if not isPickingUp then - isPickingUp = true - TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false) - QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, {}, {}, {}, function() -- Done - ClearPedTasks(PlayerPedId()) - SetEntityAsMissionEntity(nearbyObject, false, true) - DeleteObject(nearbyObject) - table.remove(weedPlants, nearbyID) - spawnedWeeds -= 1 - TriggerServerEvent('ps-drugprocessing:pickedUpCannabis') - isPickingUp = false - end, function() - ClearPedTasks(PlayerPedId()) - isPickingUp = false - end) - end - end +RegisterNetEvent('ps-drugprocessing:addWeed', function(location) + local model = GetHashKey(GlobalState.psWeed[location].model) + ps.requestModel(model) + weedPlants[location] = CreateObject(model, GlobalState.psWeed[location].loc.x, GlobalState.psWeed[location].loc.y, GlobalState.psWeed[location].loc.z, false, true, false) + PlaceObjectOnGroundProperly(weedPlants[location]) + FreezeEntityPosition(weedPlants[location], true) + ps.entityTarget(weedPlants[location], { + { + icon = "fas fa-seedling", + label = Lang:t("weed.pick_weed"), + action = function() + if weedPlants[location] then + if not ps.progressbar('Picking Weed', 5000, 'uncuff') then return end + TriggerServerEvent('ps-drugprocessing:pickedUpCannabis', location) + end + end, + }, + }) end) AddEventHandler('onResourceStop', function(resource) @@ -279,39 +156,4 @@ AddEventHandler('onResourceStop', function(resource) DeleteObject(v) end end -end) - -RegisterNetEvent('ps-drugprocessing:client:rollJoint', function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - RollJoint() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {marijuana = 1}) -end) - -RegisterNetEvent('ps-drugprocessing:client:bagskunk', function() - QBCore.Functions.TriggerCallback('ps-drugprocessing:validate_items', function(result) - if result.ret then - BagSkunk() - else - QBCore.Functions.Notify(Lang:t("error.no_item", {item = result.item})) - end - end, {marijuana = 1}) -end) - -CreateThread(function() - local weedZone = CircleZone:Create(Config.CircleZones.WeedField.coords, 10.0, { - name = "ps-weedzone", - debugPoly = false - }) - weedZone:onPlayerInOut(function(isPointInside, point, zone) - if isPointInside then - inWeedField = true - SpawnWeedPlants() - else - inWeedField = false - end - end) -end) +end) \ No newline at end of file diff --git a/config.lua b/config.lua index 2b83643..e325344 100644 --- a/config.lua +++ b/config.lua @@ -1,45 +1,86 @@ Config = {} - +ps = exports.ps_lib:init() Config.KeyRequired = true - -Config.Delays = { - WeedProcessing = 1000 * 10, - MethProcessing = 1000 * 10, - CokeProcessing = 1000 * 10, - lsdProcessing = 1000 * 10, - HeroinProcessing = 1000 * 10, - thionylchlorideProcessing = 1000 * 10, +Config.Drugs = { + coke = { + {loc = vector3(2812.77, 4785.87, 46.61), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2824.06, 4778.93, 47.34), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2826.23, 4760.15, 46.69), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2814.22, 4744.70, 45.73), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2794.96, 4754.71, 45.32), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2791.65, 4772.15, 45.87), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2789.54, 4783.35, 45.35), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2798.90, 4788.74, 45.65), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + {loc = vector3(2808.10, 4778.35, 46.11), taken = false, model = 'h4_prop_bush_cocaplant_01'}, + }, + WeedPlants = { + {loc = vector3(2215.61, 5579.80, 52.95), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2213.41, 5580.08, 52.93), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2211.25, 5580.06, 53.02), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2210.29, 5580.22, 53.07), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2214.72, 5577.55, 52.82), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2212.53, 5577.69, 52.81), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2211.35, 5577.83, 52.87), taken = false, model = 'mw_weed_plant'}, + {loc = vector3(2210.29, 5577.90, 52.92), taken = false, model = 'mw_weed_plant'}, + }, + chemicals = { + {loc = vector3(1270.48, 1802.08, 82.54), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1262.18, 1794.47, 81.93), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1253.49, 1799.48, 80.70), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1227.22, 1800.42, 78.26), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1231.96, 1820.09, 78.75), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1245.61, 1822.07, 79.77), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1263.07, 1825.05, 81.43), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1278.00, 1845.10, 82.98), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1297.92, 1830.62, 85.96), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1306.34, 1798.88, 87.68), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1288.02, 1787.11, 85.26), taken = false, model = 'mw_chemical_barrel'}, + {loc = vector3(1274.21, 1779.28, 83.79), taken = false, model = 'mw_chemical_barrel'}, + }, + heroin = { + {loc = vector3(-2336.02, -50.96, 95.46), taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2331.68, -51.34, 95.25), taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2341.43, -48.82, 93.74), taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2338.45, -60.05, 92.55), taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2343.20, -60.20, 91.84), taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2345.42, -52.04, 92.01), taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2323.90, -34.88, 100.04),taken = false, model = 'prop_plant_01b'}, + {loc = vector3(-2314.72, -8.38, 102.47), taken = false, model = 'prop_plant_01b'}, + }, + hydro = { + {loc = vector3(-1074.19, 4929.44, 211.55), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1072.89, 4943.10, 211.62), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1085.32, 4952.85, 214.53), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1071.05, 4950.43, 211.88), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1065.21, 4947.90, 211.13), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1057.18, 4944.42, 209.80), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1063.33, 4926.76, 210.14), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1067.10, 4920.27, 211.71), taken = false, model = 'mw_hydro_barrel'}, + {loc = vector3(-1089.31, 4923.88, 213.76), taken = false, model = 'mw_hydro_barrel'}, + }, + sodium = { + {loc = vector3(-392.80, -1879.73, 19.52), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-397.60, -1873.89, 19.52), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-397.04, -1868.84, 19.66), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-389.00, -1866.19, 19.66), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-381.89, -1870.62, 19.52), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-380.35, -1890.85, 20.53), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-387.77, -1874.07, 19.52), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-393.16, -1877.98, 19.52), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-374.73, -1877.74, 19.52), taken = false, model = 'mw_sodium_barrel'}, + {loc = vector3(-375.79, -1871.35, 19.52), taken = false, model = 'mw_sodium_barrel'}, + }, + sulfur = { + {loc = vector3(-3025.91, 3340.92, 9.00), taken = false, model = 'mw_sulfuric_barrel'}, + {loc = vector3(-3032.29, 3338.64, 9.13), taken = false, model = 'mw_sulfuric_barrel'}, + {loc = vector3(-3027.97, 3328.27, 9.13), taken = false, model = 'mw_sulfuric_barrel'}, + {loc = vector3(-3016.29, 3324.36, 9.02), taken = false, model = 'mw_sulfuric_barrel'}, + {loc = vector3(-3030.60, 3322.89, 9.37), taken = false, model = 'mw_sulfuric_barrel'}, + {loc = vector3(-3031.21, 3331.28, 9.03), taken = false, model = 'mw_sulfuric_barrel'}, + {loc = vector3(-3046.94, 3350.62, 6.47), taken = false, model = 'mw_sulfuric_barrel'}, + } } -Config.CircleZones = { - WeedField = {coords = vector3(2224.64, 5577.03, 53.85), name = ('Weed Farm'), radius = 100.0}, - WeedProcessing = {coords = vector3(1038.33, -3204.44, -38.17), name = ('Weed Process'), radius = 100.0}, - - MethProcessing = {coords = vector3(978.17, -147.98, -48.53), name = ('Meth Process'), radius = 20.0}, - MethTemp = {coords = vector3(982.56, -145.59, -49.0), name = ('Meth Temperature'), radius = 20.0}, - MethBag = {coords = vector3(987.81, -140.43, -49.0), name = ('Meth Bagging'), radius = 20.0}, - HydrochloricAcidFarm = {coords = vector3(-1069.25, 4945.57, 212.18), name = ('Hydrochloric Acid'), radius = 100.0}, - - SulfuricAcidFarm = {coords = vector3(-3026.89, 3334.91, 10.04), name = ('Sulfuric Acid'), radius = 100.0}, - SodiumHydroxideFarm = {coords = vector3(-389.35, -1874.85, 20.53), name = ('Sodium Hydroxide'), radius = 100.0}, - - ChemicalsField = {coords = vector3(1264.97, 1803.96, 82.94), name = ('Chemicals'), radius = 100.0}, - ChemicalsConvertionMenu = {coords = vector3(3536.71, 3662.63, 28.12), name = ('Chemicals Process'), radius = 100.0}, - - CokeField = {coords = vector3(2806.5, 4774.46, 46.98), name = ('Coke'), radius = 100.0}, - CokeProcessing = {coords = vector3(1087.14, -3195.31, -38.99), name = ('Coke Process'), radius = 20.0}, - CokePowder = {coords = vector3(1092.9, -3196.65, -38.99), name = ('Powder Cutting'), radius = 20.0},--vector3(1092.9, -3196.65, -38.99) - CokeBrick = {coords = vector3(1099.57, -3194.35, -38.99), name = ('Brick Up Packages'), radius = 20.0},--vector3(1099.57, -3194.35, -38.99) - - HeroinField = {coords = vector3(-2339.15, -54.32, 95.05), name = ('Heroin'), radius = 100.0}, - HeroinProcessing = {coords = vector3(1413.37, -2041.74, 52.0), name = ('Heroin Process'), radius = 100.0}, - - lsdProcessing = {coords = vector3(2503.84, -428.11, 92.99), name = ('LSD process'), radius = 100.0}, - - thionylchlorideProcessing = {coords = vector3(-679.59, 5800.46, 17.33), name = ('Thi Clo Process'), radius = 100.0}, -} - - Config.MethLab = { ["enter"] = { coords = vector4(-1187.17, -446.24, 43.91, 306.59), diff --git a/server/chemicals.lua b/server/chemicals.lua index c21384f..f2fb026 100644 --- a/server/chemicals.lua +++ b/server/chemicals.lua @@ -1,100 +1,100 @@ -local QBCore = exports['qb-core']:GetCoreObject() -RegisterServerEvent('ps-drugprocessing:pickedUpChemicals', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) +GlobalState.psChem = Config.Drugs.chemicals - if Player.Functions.AddItem("chemicals", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["chemicals"], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.chemicals"), "success") +local function cooldownChems(location) + if Config.Drugs.chemicals[location] then + Config.Drugs.chemicals[location].taken = true + GlobalState.psChem = Config.Drugs.chemicals + TriggerClientEvent('ps-drugprocessing:removeChem', -1, location) + CreateThread(function() + Wait(1000 * 10) + Config.Drugs.chemicals[location].taken = false + GlobalState.psChem = Config.Drugs.chemicals + TriggerClientEvent('ps-drugprocessing:addChem', -1, location) + end) + end +end +RegisterServerEvent('ps-drugprocessing:pickedUpChemicals', function(location) + local src = source + if Config.Drugs.chemicals[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get chemicals at " .. location .. ' but it was set to taken') + return + end + if not ps.checkDistance(src, Config.Drugs.chemicals[location].loc, 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return + end + if ps.addItem(src, "chemicals", 1) then + cooldownChems(location) + ps.notify(src, Lang:t("success.chemicals"), "success") end end) RegisterServerEvent('ps-drugprocessing:processHydrochloric_acid', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('chemicals', 1) then - if Player.Functions.AddItem('hydrochloric_acid', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['chemicals'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['hydrochloric_acid'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.hydrochloric_acid"), "success") - else - Player.Functions.AddItem('chemicals', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicals"), "error") + local dist = ps.checkDistance(src, vector3(3535.66, 3661.69, 28.12), 2.0) + if not dist then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + chemicals = 1, + }, + give = { + hydrochloric_acid = 1, + }, + }) end) RegisterServerEvent('ps-drugprocessing:processsodium_hydroxide', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('chemicals', 1) then - if Player.Functions.AddItem('sodium_hydroxide', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['chemicals'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['sodium_hydroxide'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.sodium_hydroxide"), "success") - else - Player.Functions.AddItem('chemicals', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicals"), "error") + local dist = ps.checkDistance(src, vector3(3535.66, 3661.69, 28.12), 2.0) + if not dist then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + chemicals = 1, + }, + give = { + sodium_hydroxide = 1, + }, + }) end) RegisterServerEvent('ps-drugprocessing:processprocess_sulfuric_acid', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('chemicals', 1) then - if Player.Functions.AddItem('sulfuric_acid', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['chemicals'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['sulfuric_acid'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.sulfuric_acid"), "success") - else - Player.Functions.AddItem('chemicals', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicals"), "error") + local dist = ps.checkDistance(src, vector3(3535.66, 3661.69, 28.12), 2.0) + if not dist then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + chemicals = 1, + }, + give = { + sulfuric_acid = 1, + }, + }) end) RegisterServerEvent('ps-drugprocessing:process_lsa', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('chemicals', 1) then - if Player.Functions.AddItem('lsa', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['chemicals'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['lsa'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.lsa"), "success") - else - Player.Functions.AddItem('chemicals', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicals"), "error") + local dist = ps.checkDistance(src, vector3(3535.66, 3661.69, 28.12), 2.0) + if not dist then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + chemicals = 1, + }, + give = { + lsa = 1, + }, + }) + end) - - -QBCore.Functions.CreateCallback('ps-drugprocessing:validate_items', function(source, cb, data) - local Player = QBCore.Functions.GetPlayer(source) - if not Player then return end - - local hasItems = { - ret = true, - items = {} - } - for name,amount in pairs(data) do - local item = Player.Functions.GetItemByName(name) - if not item or item and item.amount < amount then - hasItems.ret = false - hasItems.items[#hasItems.items+1] = QBCore.Shared.Items[name].label - end - if not hasItems then break end - end - hasItems.item = table.concat(hasItems.items, ", ") - cb(hasItems) -end) \ No newline at end of file diff --git a/server/coke.lua b/server/coke.lua index 7cab450..3b46c56 100644 --- a/server/coke.lua +++ b/server/coke.lua @@ -1,69 +1,78 @@ local QBCore = exports['qb-core']:GetCoreObject() +GlobalState.psCoke = Config.Drugs.coke -RegisterServerEvent('ps-drugprocessing:pickedUpCocaLeaf', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) +local function cooldownCoke(location) + if Config.Drugs.coke[location] then + Config.Drugs.coke[location].taken = true + GlobalState.psCoke = Config.Drugs.coke + TriggerClientEvent('ps-drugprocessing:removeCocaLeaf', -1, location) + CreateThread(function() + Wait(1000 * 10) + Config.Drugs.coke[location].taken = false + GlobalState.psCoke = Config.Drugs.coke + TriggerClientEvent('ps-drugprocessing:addCocaLeaf', -1, location) + end) + end +end - if Player.Functions.AddItem("coca_leaf", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["coca_leaf"], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.coca_leaf"), "success") - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_coca_leaf"), "error") +RegisterServerEvent('ps-drugprocessing:pickedUpCocaLeaf', function(location) + local src = source + if Config.Drugs.coke[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get coca leaf at " .. location .. ' but it was set to taken') + return + end + if not ps.checkDistance(src, Config.Drugs.coke[location].loc, 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return + end + if ps.addItem(src, "coca_leaf", 1) then + cooldownCoke(location) + ps.notify(src, Lang:t("success.coca_leaf"), "success") end end) RegisterServerEvent('ps-drugprocessing:processCocaLeaf', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('coca_leaf', Config.CokeProcessing.CokeLeaf) then - if Player.Functions.AddItem('coke', Config.CokeProcessing.ProcessCokeLeaf) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['coca_leaf'], "remove", Config.CokeProcessing.CokeLeaf) - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['coke'], "add", Config.CokeProcessing.ProcessCokeLeaf) - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.coke"), "success") - else - Player.Functions.AddItem('coca_leaf', Config.CokeProcessing.CokeLeaf) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_coca_leaf"), "error") + if not ps.checkDistance(src, vector3(1086.2, -3194.9, -38.99), 2.0) then + return end + ps.craftItem(src, { + take = { + coca_leaf = Config.CokeProcessing.CokeLeaf, + }, + give = { + coke = Config.CokeProcessing.ProcessCokeLeaf, + } + }) end) RegisterServerEvent('ps-drugprocessing:processCocaPowder', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('coke', Config.CokeProcessing.Coke) then - if Player.Functions.RemoveItem('bakingsoda', Config.CokeProcessing.BakingSoda) then - if Player.Functions.AddItem('coke_small_brick', Config.CokeProcessing.SmallCokeBrick) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['coke'], "remove", Config.CokeProcessing.Coke) - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['bakingsoda'], "remove", Config.CokeProcessing.BakingSoda) - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['coke_small_brick'], "add", Config.CokeProcessing.SmallCokeBrick) - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.coke_small_brick"), "success") - else - Player.Functions.AddItem('coke', Config.CokeProcessing.Coke) - Player.Functions.AddItem('bakingsoda', Config.CokeProcessing.BakingSoda) - end - else - Player.Functions.AddItem('coke', Config.CokeProcessing.Coke) - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_bakingsoda"), "error") - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_cokain"), "error") + if not ps.checkDistance(src, vector3(1092.89, -3195.78, -38.99), 2.0) then + return end + ps.craftItem(src, { + take = { + coke = Config.CokeProcessing.Coke, + bakingsoda = Config.CokeProcessing.BakingSoda, + }, + give = { + cokepowder = Config.CokeProcessing.CokePowder, + } + }) end) RegisterServerEvent('ps-drugprocessing:processCocaBrick', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('coke_small_brick', Config.CokeProcessing.SmallBrick) then - if Player.Functions.AddItem('coke_brick', Config.CokeProcessing.LargeBrick) then - TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items['coke_small_brick'], "remove", Config.CokeProcessing.SmallBrick) - TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items['coke_brick'], "add", Config.CokeProcessing.LargeBrick) - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.coke_brick"), "success") - else - Player.Functions.AddItem('coke_small_brick', Config.CokeProcessing.SmallBrick) - end + if not ps.checkDistance(src, vector3(1100.51, -3199.46, -38.93), 2.0) then + return end + ps.craftItem(src, { + take = { + coke_small_brick = Config.CokeProcessing.SmallBrick, + }, + give = { + coke_brick = Config.CokeProcessing.LargeBrick, + } + }) end) diff --git a/server/heroin.lua b/server/heroin.lua index f08d446..98e5027 100644 --- a/server/heroin.lua +++ b/server/heroin.lua @@ -1,28 +1,47 @@ -local QBCore = exports['qb-core']:GetCoreObject() +GlobalState.psHeroin = Config.Drugs.heroin -RegisterServerEvent('ps-drugprocessing:pickedUpPoppy', function() +local function cooldownPoppy(location) + if Config.Drugs.heroin[location] then + Config.Drugs.heroin[location].taken = true + GlobalState.psHeroin = Config.Drugs.heroin + TriggerClientEvent('ps-drugprocessing:removePoppy', -1, location) + CreateThread(function() + Wait(1000 * 10) + Config.Drugs.heroin[location].taken = false + GlobalState.psHeroin = Config.Drugs.heroin + TriggerClientEvent('ps-drugprocessing:addPoppy', -1, location) + end) + end +end +RegisterServerEvent('ps-drugprocessing:pickedUpPoppy', function(location) local src = source - local Player = QBCore.Functions.GetPlayer(src) + if not ps.checkDistance(src, Config.Drugs.heroin[location].loc, 2.0) then + ps.debug(src, Lang:t("error.not_in_range"), "error") + return + end + if Config.Drugs.heroin[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get Poppy at " .. location .. ' but it was set to taken') + return + end - if Player.Functions.AddItem("poppyresin", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["poppyresin"], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.poppyresin"), "success") + if ps.addItem(src, "poppyresin", 1) then + cooldownPoppy(location) + ps.notify(src, Lang:t("success.poppyresin"), "success") end end) RegisterServerEvent('ps-drugprocessing:processPoppyResin', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('poppyresin', Config.HeroinProcessing.Poppy) then - if Player.Functions.AddItem('heroin', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['poppyresin'], "remove", Config.HeroinProcessing.Poppy) - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['heroin'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.heroin"), "success") - else - Player.Functions.AddItem('poppyresin', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_poppy_resin"), "error") + if not ps.checkDistance(src, vector3(1384.9, -2080.61, 52.21), 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + poppyresin = Config.HeroinProcessing.Poppy, + }, + give = { + heroin = 1, + } + }) end) diff --git a/server/lsd.lua b/server/lsd.lua index f5e4ff7..ef5d2a0 100644 --- a/server/lsd.lua +++ b/server/lsd.lua @@ -2,44 +2,34 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('ps-drugprocessing:Processlsd', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem("lsa", 1) then - if Player.Functions.RemoveItem("thionyl_chloride", 1) then - if Player.Functions.AddItem("lsd", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["lsd"], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.lsd"), "success") - else - Player.Functions.AddItem("lsa", 1) - Player.Functions.AddItem("thionyl_chloride", 1) - end - else - Player.Functions.AddItem("lsa", 1) - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_thionyl_chloride"), "error") - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_lsa"), "error") + if not ps.checkDistance(src, vector3(2503.53, -427.48, 92.99), 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + lsa = 1, + thionyl_chloride = 1, + }, + give = { + lsd = 1, + } + }) end) RegisterServerEvent('ps-drugprocessing:processThionylChloride', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem("lsa", 1) then - if Player.Functions.RemoveItem("chemicals", 1) then - if Player.Functions.AddItem("thionyl_chloride", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["thionyl_chloride"], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.thionyl_chloride"), "success") - else - Player.Functions.AddItem("lsa", 1) - Player.Functions.AddItem("chemicals", 1) - end - else - Player.Functions.AddItem("lsa", 1) - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicals"), "error") - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_lsa"), "error") + if not ps.checkDistance(src, vector3(-679.77, 5800.7, 17.33), 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + lsa = 1, + chemicals = 1, + }, + give = { + thionyl_chloride = 1, + } + }) end) diff --git a/server/meth.lua b/server/meth.lua index c543cd6..ae38e4e 100644 --- a/server/meth.lua +++ b/server/meth.lua @@ -1,126 +1,174 @@ -local QBCore = exports['qb-core']:GetCoreObject() -RegisterServerEvent('ps-drugprocessing:pickedUpHydrochloricAcid', function() +GlobalState.psHydro = Config.Drugs.hydro +GlobalState.psSodium = Config.Drugs.sodium +GlobalState.psSulfuric = Config.Drugs.sulfuric + +local function cooldownHydro(location) + if Config.Drugs.hydro[location] then + Config.Drugs.hydro[location].taken = true + GlobalState.psHydro = Config.Drugs.hydro + TriggerClientEvent('ps-drugprocessing:removeHydrochloricAcid', -1, location) + CreateThread(function() + Wait(1000 * 10) + Config.Drugs.hydro[location].taken = false + GlobalState.psHydro = Config.Drugs.hydro + TriggerClientEvent('ps-drugprocessing:addHydrochloricAcid', -1, location) + end) + end +end + +RegisterServerEvent('ps-drugprocessing:pickedUpHydrochloricAcid', function(location) local src = source - local Player = QBCore.Functions.GetPlayer(src) + if not ps.checkDistance(src, Config.Drugs.hydro[location].loc, 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return + end + if Config.Drugs.hydro[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get hydrochloric acid at " .. location .. ' but it was set to taken') + return + end - if Player.Functions.AddItem("hydrochloric_acid", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["hydrochloric_acid"], "add") + if ps.addItem(src,"hydrochloric_acid", 1) then + cooldownHydro(location) + ps.notify(src, Lang:t("success.hydrochloric_acid"), "success") end end) -RegisterServerEvent('ps-drugprocessing:pickedUpSodiumHydroxide', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) +local function cooldownSodium(location) + if Config.Drugs.sodium[location] then + Config.Drugs.sodium[location].taken = true + GlobalState.psSodium = Config.Drugs.sodium + TriggerClientEvent('ps-drugprocessing:removeSodiumHydroxide', -1, location) + CreateThread(function() + Wait(1000 * 10) + Config.Drugs.sodium[location].taken = false + GlobalState.psSodium = Config.Drugs.sodium + TriggerClientEvent('ps-drugprocessing:addSodiumHydroxide', -1, location) + end) + end +end - if Player.Functions.AddItem("sodium_hydroxide", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["sodium_hydroxide"], "add") +RegisterServerEvent('ps-drugprocessing:pickedUpSodiumHydroxide', function(location) + local src = source + if not ps.checkDistance(src, Config.Drugs.sodium[location].loc, 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return + end + if Config.Drugs.sodium[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get sodium hydroxide at " .. location .. ' but it was set to taken') + return + end + if ps.addItem(src, "sodium_hydroxide", 1) then + cooldownSodium(location) + ps.notify(src, Lang:t("success.sodium_hydroxide"), "success") end end) -RegisterServerEvent('ps-drugprocessing:pickedUpSulfuricAcid', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.AddItem("sulfuric_acid", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["sulfuric_acid"], "add") +local function cooldownSulfuric(location) + if Config.Drugs.sulfuric[location] then + Config.Drugs.sulfuric[location].taken = true + GlobalState.psSulfuric = Config.Drugs.sulfuric + TriggerClientEvent('ps-drugprocessing:removeSulfuricAcid', -1, location) + CreateThread(function() + Wait(1000 * 10) + Config.Drugs.sulfuric[location].taken = false + GlobalState.psSulfuric = Config.Drugs.sulfuric + TriggerClientEvent('ps-drugprocessing:addSulfuricAcid', -1, location) + end) + end +end + +RegisterServerEvent('ps-drugprocessing:pickedUpSulfuricAcid', function(location) + local src = source + if not ps.checkDistance(src, Config.Drugs.sulfuric[location].loc, 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return + end + if Config.Drugs.sulfuric[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get sulfuric acid at " .. location .. ' but it was set to taken') + return + end + if ps.addItem("sulfuric_acid", 1) then + cooldownSulfuric(location) + ps.notify(src, Lang:t("success.sulfuric_acid"), "success") end end) + +---- RegisterServerEvent('ps-drugprocessing:processChemicals', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem("sulfuric_acid", Config.MethProcessing.SulfAcid) then - if Player.Functions.RemoveItem("hydrochloric_acid", Config.MethProcessing.HydAcid) then - if Player.Functions.RemoveItem("sodium_hydroxide", Config.MethProcessing.SodHyd) then - if Player.Functions.AddItem("liquidmix", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["sulfuric_acid"], "remove", Config.MethProcessing.SulfAcid) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["hydrochloric_acid"], "remove", Config.MethProcessing.HydAcid) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["sodium_hydroxide"], "remove", Config.MethProcessing.SodHyd) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["liquidmix"], "add", 1) - else - Player.Functions.AddItem("sulfuric_acid", Config.MethProcessing.SulfAcid) - Player.Functions.AddItem("hydrochloric_acid", Config.MethProcessing.HydAcid) - Player.Functions.AddItem("sodium_hydroxide", Config.MethProcessing.SodHyd) - end - else - Player.Functions.AddItem("sulfuric_acid", Config.MethProcessing.SulfAcid) - Player.Functions.AddItem("hydrochloric_acid", Config.MethProcessing.HydAcid) - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_sodium_hydroxide"), "error") - end - else - Player.Functions.AddItem("sulfuric_acid", Config.MethProcessing.SulfAcid) - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_hydrochloric_acid"), "error") - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_sulfuric_acid"), "error") + if not ps.checkDistance(src, vector3(978.22, -147.1, -48.53), 5.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end - + ps.craftItem(src, { + take = { + sulfuric_acid = Config.MethProcessing.SulfAcid, + hydrochloric_acid = Config.MethProcessing.HydAcid, + sodium_hydroxide = Config.MethProcessing.SodHyd, + }, + give = { + liquidmix = 1, + } + }) end) RegisterServerEvent('ps-drugprocessing:processTempUp', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem("liquidmix", 1) then - if Player.Functions.AddItem("chemicalvapor", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["liquidmix"], "remove") - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["chemicalvapor"], "add") - else - Player.Functions.AddItem("liquidmix", 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_liquidmix"), "error") + if not ps.checkDistance(src, vector3(982.56, -145.59, -49.0), 5.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + liquidmix = 1, + }, + give = { + chemicalvapor = 1, + } + }) end) RegisterServerEvent('ps-drugprocessing:processTempDown', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem("chemicalvapor", 1) then - if Player.Functions.AddItem("methtray", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["chemicalvapor"], "remove") - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["methtray"], "add") - else - Player.Functions.AddItem("chemicalvapor", 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicalvapor"), "error") + if not ps.checkDistance(src, vector3(979.59, -144.14, -49.0), 5.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end - + ps.craftItem(src, { + take = { + chemicalvapor = 1, + }, + give = { + methtray = 1, + } + }) end) RegisterServerEvent('ps-drugprocessing:processMeth', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.RemoveItem("methtray", 1) then - if Player.Functions.AddItem("meth", Config.MethProcessing.Meth) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["methtray"], "remove") - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["meth"], "add", Config.MethProcessing.Meth) - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.meth"), "success") - else - Player.Functions.AddItem("methtray", 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_chemicalvapor"), "error") + if not ps.checkDistance(src, vector3(987.44, -140.5, -49.0), 5.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return end + ps.craftItem(src, { + take = { + methtray = 1, + }, + give = { + meth = Config.MethProcessing.Meth, + } + }) end) RegisterServerEvent('ps-drugprocessing:processFailUp', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - Player.Functions.RemoveItem("liquidmix", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["liquidmix"], "remove") - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.temp_too_high"), "error") + ps.removeItem(src, "liquidmix", 1) end) RegisterServerEvent('ps-drugprocessing:processFailDown', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - Player.Functions.RemoveItem("chemicalvapor", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["chemicalvapor"], "remove") - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.temp_too_low"), "error") + ps.removeItem(src, "chemicalvapor", 1) end) diff --git a/server/weed.lua b/server/weed.lua index dd939a4..61d33f5 100644 --- a/server/weed.lua +++ b/server/weed.lua @@ -1,84 +1,95 @@ -local QBCore = exports['qb-core']:GetCoreObject() -RegisterServerEvent('ps-drugprocessing:pickedUpCannabis', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) +GlobalState.psWeed = Config.Drugs.WeedPlants + +local function cooldownWeed(location) + if Config.Drugs.WeedPlants[location] then + Config.Drugs.WeedPlants[location].taken = true + GlobalState.psWeed = Config.Drugs.WeedPlants + TriggerClientEvent('ps-drugprocessing:removeWeed', -1, location) + CreateThread(function() + Wait(1000 * 5) + Config.Drugs.WeedPlants[location].taken = false + GlobalState.psWeed = Config.Drugs.WeedPlants + TriggerClientEvent('ps-drugprocessing:addWeed', -1, location) + end) + end +end - if Player.Functions.AddItem("cannabis", 1) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["cannabis"], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.cannabis"), "success") +RegisterServerEvent('ps-drugprocessing:pickedUpCannabis', function(location) + local src = source + if Config.Drugs.WeedPlants[location].taken then + ps.debug(ps.getPlayerName(src) .. " Tried to Get Weed at " .. location .. ' but it was set to taken') + return + end + if not ps.checkDistance(src, Config.Drugs.WeedPlants[location].loc, 2.0) then + ps.notify(src, Lang:t("error.not_in_range"), "error") + return + end + if ps.addItem(src,"cannabis", 1) then + cooldownWeed(location) + ps.notify(src, Lang:t("success.cannabis"), "success") end end) RegisterServerEvent('ps-drugprocessing:processCannabis', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('cannabis', 1) then - if Player.Functions.AddItem('marijuana', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['cannabis'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['marijuana'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.marijuana"), "success") - else - Player.Functions.AddItem('cannabis', 1) + if not ps.checkDistance(src, vector3(1038.33, -3204.44, -38.17), 2.0) then + return + end + if ps.removeItem(src, 'cannabis', 1) then + if ps.addItem(src, 'marijuana', 1) then + ps.notify(src, Lang:t("success.processed_cannabis"), "success") end else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_cannabis"), "error") + ps.notify(src, Lang:t("error.no_cannabis"), "error") end end) -RegisterServerEvent('ps-drugprocessing:rollJoint', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('marijuana', 1) then - if Player.Functions.RemoveItem('rolling_paper', 1) then - if Player.Functions.AddItem('joint', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['marijuana'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['rolling_paper'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['joint'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.joint"), "success") - else - Player.Functions.AddItem('marijuana', 1) - Player.Functions.AddItem('rolling_paper', 1) - end - else - Player.Functions.AddItem('marijuana', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_marijuhana"), "error") +ps.createUseable("rolling_paper", function(source, item) + if not ps.verifyRecipe(source, { + rolling_paper = 1, + marijuana = 1 + }) then + ps.notify(source, Lang:t("error.no_item", {item = "marijuana"}), "error") + return end + TriggerClientEvent('ps-drugprocessing:client:rollJoint', source) end) -QBCore.Functions.CreateUseableItem("rolling_paper", function(source, item) - local Player = QBCore.Functions.GetPlayer(source) - TriggerClientEvent('ps-drugprocessing:client:rollJoint', source, 'marijuana', item) +ps.createUseable("empty_weed_bag", function(source, item) + if not ps.verifyRecipe(source, { + empty_weed_bag = 1, + marijuana = 1 + }) then + ps.notify(source, Lang:t("error.no_item", {item = "marijuana"}), "error") + return + end + TriggerClientEvent('ps-drugprocessing:client:bagskunk', source, 'marijuana', item) end) + RegisterServerEvent('ps-drugprocessing:bagskunk', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem('marijuana', 1) then - if Player.Functions.RemoveItem('empty_weed_bag', 1) then - if Player.Functions.AddItem('weed_skunk', 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['marijuana'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['empty_weed_bag'], "remove") - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['weed_skunk'], "add") - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.baggy"), "success") - else - Player.Functions.AddItem('marijuana', 1) - Player.Functions.AddItem('empty_weed_bag', 1) - end - else - Player.Functions.AddItem('marijuana', 1) - end - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_marijuhana"), "error") - end + ps.craftItem(src, { + take = { + marijuana = 1, + empty_weed_bag = 1 + }, + give = { + weed_skunk = 1 + } + }) end) -QBCore.Functions.CreateUseableItem("empty_weed_bag", function(source, item) - local Player = QBCore.Functions.GetPlayer(source) - TriggerClientEvent('ps-drugprocessing:client:bagskunk', source, 'marijuana', item) +RegisterServerEvent('ps-drugprocessing:rollJoint', function() + local src = source + ps.craftItem(src, { + take = { + marijuana = 1, + rolling_paper = 1 + }, + give = { + joint = 1 + } + }) end)