diff --git a/client/heroin.lua b/client/heroin.lua index 198183f..d474188 100644 --- a/client/heroin.lua +++ b/client/heroin.lua @@ -71,15 +71,17 @@ RegisterNetEvent("md-drugs:client:buyheroinlabkit", function() TriggerServerEvent("md-drugs:server:getheroinlabkit") end) -RegisterNetEvent("md-drugs:client:setheroinlabkit", function() +lib.callback.register("md-drugs:client:setheroinlabkit", function() if herointable then Notify(Lang.Heroin.tableout, 'error') + return false else herointable = true local location, head = StartRay() - if not location then herointable = false TriggerServerEvent('md-drugs:server:getheroinlabkitback') return end - if not progressbar(Lang.Heroin.table, 4000, 'uncuff') then TriggerServerEvent('md-drugs:server:getheroinlabkitback') return end + if not location then herointable = false return end + if not progressbar(Lang.Heroin.table, 4000, 'uncuff') then return end createLabKit(location, head) + return true, location end end) diff --git a/client/lsd.lua b/client/lsd.lua index 29a3ffb..03fef3c 100644 --- a/client/lsd.lua +++ b/client/lsd.lua @@ -28,17 +28,19 @@ RegisterNetEvent("md-drugs:client:getdiethylamide", function(data) TriggerServerEvent('md-drugs:server:getdiethylamide', data.data) end) -RegisterNetEvent("md-drugs:client:setlsdlabkit", function() -if tableout then - Notify(Lang.lsd.tableout, 'error') - TriggerServerEvent('md-drugs:server:getlabkitback') -else - tableout = true - local loc, head = StartRay() - if not loc then tableout = false TriggerServerEvent('md-drugs:server:getlabkitback') return end - if not progressbar(Lang.lsd.place, 4000, 'uncuff') then TriggerServerEvent('md-drugs:server:getlabkitback') return end - createLabKit(loc, head) -end + +lib.callback.register("md-drugs:client:setlsdlabkit", function() + if tableout then + Notify(Lang.lsd.tableout, 'error') + return false + else + tableout = true + local loc, head = StartRay() + if not loc then tableout = false return end + if not progressbar(Lang.lsd.place, 4000, 'uncuff') then return end + createLabKit(loc, head) + return true, loc + end end) RegisterNetEvent("md-drugs:client:getlabkitback", function(data) @@ -63,22 +65,22 @@ RegisterNetEvent("md-drugs:client:heatliquid", function(data) PlaceObjectOnGroundProperly(dirtylabkit) SetParticleFxLoopedAlpha(exitPtfx, 3.0) Wait(100) - AddMultiModel(dirtylabkit, { event = "md-drugs:client:cleanlabkit", icon = "fa-solid fa-hand-sparkles", label = Lang.targets.lsd.clean, data = dirtylabkit}, nil ) + AddSingleModel(dirtylabkit, {icon = "fa-solid fa-hand-sparkles", label = Lang.targets.lsd.clean, data = dirtylabkit, + action = function() + if not ItemCheck('cleaningkit') then return end + if not progressbar(Lang.lsd.clean, 4000, 'clean') then return end + local check = lib.callback.await('md-drugs:server:removecleaningkit') + if check then + DeleteObject(dirtylabkit) + createLabKit(PedCoords, head) + end + end + }, nil ) return end if not progressbar(Lang.lsd.heat, 7000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:heatliquid") end) -RegisterNetEvent("md-drugs:client:cleanlabkit", function(data) - if not ItemCheck('cleaningkit') then return end - if not progressbar(Lang.lsd.clean, 4000, 'clean') then return end - local check = lib.callback.await('md-drugs:server:removecleaningkit') - if check then - local coord, head = GetEntityCoords(data.data), GetEntityHeading(data.data) - DeleteObject(data.data) - createLabKit(coord, head) - end -end) RegisterNetEvent("md-drugs:client:refinequalityacid", function() if not ItemCheck('lsd_one_vial') then return end diff --git a/client/meth.lua b/client/meth.lua index a18bb0c..fb27273 100644 --- a/client/meth.lua +++ b/client/meth.lua @@ -115,25 +115,6 @@ CreateThread(function() end end) -CreateThread(function() -if not Config.MethHeist == false then - local current = "g_m_y_famdnf_01" - lib.requestModel(current, Config.RequestModelTime) - local CurrentLocation = Config.MethHeistStart - local methdealer = CreatePed(0, current, CurrentLocation.x, CurrentLocation.y, CurrentLocation.z - 1, false, false) - Freeze(methdealer, true, 220.0) - Wait(100) - AddSingleModel(methdealer,{ - label = Lang.targets.meth.mission, - icon = "fas fa-eye", - action = function() - Notify(Lang.meth.mission, "success") - SpawnMethCarPedChase() - end, - },nil ) -end -end) - RegisterNetEvent("md-drugs:client:stealeph", function(data) if not progressbar('Stealing Ephedrine', 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:geteph", data.data) diff --git a/client/oxyruns.lua b/client/oxyruns.lua index 68e23c3..9714781 100644 --- a/client/oxyruns.lua +++ b/client/oxyruns.lua @@ -5,7 +5,8 @@ RegisterNetEvent("md-drugs:client:GetOxyCar", function() lib.requestModel("burrito3", Config.RequestModelTime) local paid = lib.callback.await('md-drugs:server:payfortruck', false) if not paid then return end - local oxycar = CreateVehicle("burrito3",Config.truckspawn.x, Config.truckspawn.y,Config.truckspawn.z, Config.truckspawn.w, true, false) + local loc = lib.callback.await('md-drugs:server:getLocs', false) + local oxycar = CreateVehicle("burrito3",loc.singleSpot.truckspawn.x, loc.singleSpot.truckspawn.y,loc.singleSpot.truckspawn.z, loc.singleSpot.truckspawn.w, true, false) exports[Config.Fuel]:SetFuel(oxycar, 100.0) TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(oxycar)) Notify(Lang.oxy.truck, 'success') diff --git a/client/pedspawns.lua b/client/pedspawns.lua index 57a2249..64accf0 100644 --- a/client/pedspawns.lua +++ b/client/pedspawns.lua @@ -12,12 +12,15 @@ CreateThread(function() local heroinkitdealer = CreatePed(0,"g_m_y_famdnf_01",config.singleSpot.buyheroinlabkit.x, config.singleSpot.buyheroinlabkit.y, config.singleSpot.buyheroinlabkit.z-1, config.singleSpot.buyheroinlabkit.w, false, false) local SyrupLocation = CreatePed(0, 's_m_m_doctor_01', config.singleSpot.SyrupVendor.x,config.singleSpot.SyrupVendor.y,config.singleSpot.SyrupVendor.z-1, config.singleSpot.SyrupVendor.w, false, false) local WeedGuy = CreatePed(0,'u_m_m_jesus_01',config.singleSpot.WeedSaleman.x,config.singleSpot.WeedSaleman.y,config.singleSpot.WeedSaleman.z-1, config.singleSpot.WeedSaleman.w, false, false) + local methdealer = CreatePed(0, "g_m_y_famdnf_01", config.singleSpot.MethHeistStart.x, config.singleSpot.MethHeistStart.y, config.singleSpot.MethHeistStart.z - 1, false, false) Freeze(tabdealer, true,config.singleSpot.buylsdlabkit.w) Freeze(SyrupLocation, true, config.singleSpot.SyrupVendor.w) Freeze(heroinkitdealer, true, config.singleSpot.buyheroinlabkit.w) Freeze(WeedGuy, true, config.singleSpot.WeedSaleman.w) + Freeze(methdealer, true, 220.0) AddSingleModel(tabdealer,{ type = "client", label = Lang.targets.lsd.buy, icon = "fa-solid fa-money-bill", event = "md-drugs:client:buylabkit", distance = 2.0}, tabdealer ) AddSingleModel(heroinkitdealer, { label = Lang.targets.heroin.kit, icon = "fa-solid fa-money-bill", event = "md-drugs:client:buyheroinlabkit", distance = 2.0}, nil ) AddSingleModel(SyrupLocation, { type = "client", label = Lang.targets.lean.git, icon = "fa-solid fa-circle-info", event = "md-drugs:client:getsyruplocationtobuy", distance = 2.0}, nil ) AddSingleModel(WeedGuy, {label = "Weed Shop",icon = "fas fa-eye", action = function() makeMenu('WeedShop') lib.showContext('WeedShop')end}, nil) + AddSingleModel(methdealer,{label = Lang.targets.meth.mission, icon = "fas fa-eye", action = function() Notify(Lang.meth.mission, "success") SpawnMethCarPedChase() end,},nil ) end) \ No newline at end of file diff --git a/server/heroin.lua b/server/heroin.lua index f899221..79f6c91 100644 --- a/server/heroin.lua +++ b/server/heroin.lua @@ -2,6 +2,7 @@ local QBCore = exports['qb-core']:GetCoreObject() local prices = { heroinlabkitprice = 10000 } +local heroinLabKits = {} local h = { { location = vector3(-2251.3, -99.18, 100.11), heading = 334.49, model = "prop_plant_01b"}, { location = vector3(-2249.63, -92.97, 101.8), heading = 329.56, model = "prop_plant_01b"}, @@ -17,6 +18,7 @@ local h = { { location = vector3(-2250.96, -111.22, 97.50), heading = 21.52, model = "prop_plant_01b"}, { location = vector3(465.95, -1021.32, 31.78), heading = 21.52, model = "prop_plant_01b"}, } + GlobalState.PoppyPlants = h Citizen.CreateThread(function() for _, v in pairs(h) do @@ -110,28 +112,55 @@ RegisterServerEvent('md-drugs:server:getheroinlabkit', function() end end) -RegisterServerEvent('md-drugs:server:getheroinlabkitback', function() -local src = source -local Player = getPlayer(src) - if AddItem(src, "heroinlabkit", 1) then +local function hasHKit(src) + local src = source + local Player = getPlayer(src) + for k, v in pairs(heroinLabKits) do + if v.ownerid == Player.PlayerData.citizenid then + return true + end end + return false +end + +RegisterServerEvent('md-drugs:server:getheroinlabkitback', function() + local src = source + local Player = getPlayer(src) + if not hasHKit(src) then return end + for k, v in pairs (heroinLabKits) do + if v.ownerid == Player.PlayerData.citizenid then + table.remove(heroinLabKits, k) + AddItem(src, 'heroinlabkit', 1) + end + end + print(json.encode(heroinLabKits)) end) + QBCore.Functions.CreateUseableItem('heroinlabkit', function(source, item) -local src = source -local Player = getPlayer(src) + local src = source + local Player = getPlayer(src) if not Itemcheck(source, 'heroinlabkit', 1) then return end - if TriggerClientEvent("md-drugs:client:setheroinlabkit", src) then - RemoveItem(src, "heroinlabkit", 1) - Log(GetName(src) ..' Placed Their Heroin Lab Kit Back At ' .. GetCoords(src) .. '!', 'heroin') + local placed, loc = lib.callback.await('md-drugs:client:setheroinlabkit', src) + if placed then + RemoveItem(src, 'heroinlabkit', 1) + table.insert(heroinLabKits, { + src = src, + ownerid = Player.PlayerData.citizenid, + coords = loc, + name = GetName(src) + }) + Notifys(src, Lang.Heroin.placed, "success") end + print(json.encode(heroinLabKits)) end) RegisterServerEvent('md-drugs:server:heatliquidheroin', function() local src = source -local Player = getPlayer(src) +local Player = getPlayer(src) + if not hasHKit(src) then return end if not Itemcheck(source, 'emptyvial', 1) then return end if Config.TierSystem then local cuth = Player.Functions.GetItemByName('heroincut') @@ -154,6 +183,7 @@ end) RegisterServerEvent('md-drugs:server:failheatingheroin', function() local src = source local Player = getPlayer(src) +if not hasHKit(src) then return end local cuth = Player.Functions.GetItemByName('heroincut') local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo') local cuth3 = Player.Functions.GetItemByName('heroincutstagethree') @@ -216,3 +246,14 @@ RegisterServerEvent('md-drugs:server:failheroin', function() end end) +AddEventHandler('playerDropped', function() + local src = source + local Player = getPlayer(src) + for k, v in pairs(heroinLabKits) do + if v.src == src then + table.remove(heroinLabKits, k) + AddItem(src, 'heroinlabkit', 1) + end + end + json.encode(heroinLabKits) +end) \ No newline at end of file diff --git a/server/locations.lua b/server/locations.lua index 2922ee9..bfeeb91 100644 --- a/server/locations.lua +++ b/server/locations.lua @@ -69,7 +69,7 @@ local Target = { WeedSaleman = vector4(1030.77, -3203.18, -38.2, 262.37), -- where the weed saleman is MethTeleIn = vector3(-2222.04, 303.99, 174.6), -- where you target to tele in meth MethTeleOut = vector3(996.91, -3200.83, -36.39), -- where you target to tele out meth - MethHeistStart = vector3(-1102.93, -3066.76, 14.00), -- where you get the mission to get ingridients if meth heist = true + MethHeistStart = vector4(-1520.84, 827.72, 181.66, 184.13), -- where you get the mission to get ingridients if meth heist = true truckspawn = vector4(1450.87, -1482.13, 63.22, 69.95), --- where the truck will spawn when you pay for it Payfortruck = vector3(1437.64, -1491.91, 63.62), --- where you pay for the truck }, diff --git a/server/lsd.lua b/server/lsd.lua index 48c1171..ce1675c 100644 --- a/server/lsd.lua +++ b/server/lsd.lua @@ -3,6 +3,8 @@ local prices = { tabcost = 100, -- price per piece of tab paper event does 10 at a time lsdlabkitcost = 10000 -- price of the lsd lab kit } + +local lsdTables = {} RegisterServerEvent('md-drugs:server:getlysergic', function(num) local src = source if not checkLoc(src, 'lysergicacid', num) then return end @@ -19,12 +21,31 @@ end) QBCore.Functions.CreateUseableItem('lsdlabkit', function(source, item) -local src = source - if TriggerClientEvent("md-drugs:client:setlsdlabkit", src) then - RemoveItem(src, "lsdlabkit", 1) + local src = source + local Player = getPlayer(src) + local placed, loc = lib.callback.await('md-drugs:client:setlsdlabkit', src) + if placed then + if RemoveItem(src, 'lsdlabkit', 1) then + table.insert(lsdTables, { + owner = GetName(src), + ownerid = Player.PlayerData.citizenid, + src = src, + loc = loc + }) + end end + print(json.encode(lsdTables)) end) +local function hasLabKit(source) + local src = source + local Player = getPlayer(src) + for k, v in pairs (lsdTables) do + if v.ownerid == Player.PlayerData.citizenid then + return true + end + end +end lib.callback.register('md-drugs:server:removecleaningkit', function(source) local src = source @@ -36,18 +57,25 @@ end) RegisterServerEvent('md-drugs:server:getlabkitback', function() local src = source - if AddItem(src,"lsdlabkit", 1) then - Log(GetName(src) ..' Picked Up Their LSD Lab Kit Back At ' .. GetCoords(src) .. '!', 'lsd') + local Player = getPlayer(src) + for k, v in pairs (lsdTables) do + if v.ownerid == Player.PlayerData.citizenid then + table.remove(lsdTables, k) + AddItem(src, 'lsdlabkit', 1) + end end + print(json.encode(lsdTables)) end) RegisterServerEvent('md-drugs:server:heatliquid', function() local src = source + if not hasLabKit(src) then return end if not GetRecipe(src, 'lsd', 'vial', 'heat') then return end end) RegisterServerEvent('md-drugs:server:failheating', function() local src = source + if not hasLabKit(src) then return end RemoveItem(src, 'lysergic_acid', 1) RemoveItem(src, 'diethylamide', 1) Notifys(src,Lang.lsd.failed, "error") @@ -57,6 +85,7 @@ end) RegisterServerEvent('md-drugs:server:refinequalityacid', function() local src = source +if not hasLabKit(src) then return end if not Itemcheck(src, 'lsd_one_vial', 1) then return end if Config.TierSystem then local lsd = getRep(src, 'lsd') @@ -96,6 +125,7 @@ end) RegisterServerEvent('md-drugs:server:failrefinequality', function() local src = source + if not hasLabKit(src) then return end if not Itemcheck(src, 'lsd_one_vial', 1) then return end RemoveItem(src,'lsd_one_vial', 1) end) @@ -126,6 +156,7 @@ end) RegisterServerEvent('md-drugs:server:maketabpaper', function() local src = source local Player = getPlayer(src) + if not hasLabKit(src) then return end if not Itemcheck(src,'tab_paper', 1) then return end local count = 0 local items, recieve = nil, nil @@ -145,8 +176,8 @@ RegisterServerEvent('md-drugs:server:maketabpaper', function() if check and check.amount >= 1 then items = v.vial recieve = v.sheet - Log(GetName(src) ..' ' .. v.log, 'lsd') count = count + 1 + break end end if count >= 1 then @@ -175,4 +206,16 @@ for k, v in pairs (sheets) do Log(GetName(src) ..' Made ' .. math .. 'Tabs of ' .. v.recieve .. '!', 'lsd') end end) -end \ No newline at end of file +end + +AddEventHandler('playerDropped', function() + local src = source + local Player = getPlayer(src) + for k, v in pairs (lsdTables) do + if v.ownerid == Player.PlayerData.citizenid then + table.remove(lsdTables, k) + AddItem(src, 'lsdlabkit', 1) + end + end + print(json.encode(lsdTables)) +end) \ No newline at end of file diff --git a/server/xtc.lua b/server/xtc.lua index abfb597..43af67d 100644 --- a/server/xtc.lua +++ b/server/xtc.lua @@ -40,6 +40,7 @@ local check, loc = lib.callback.await('md-drugs:client:setpress', src, v.data) }) end end + print(json.encode(activePresses)) end) end @@ -237,4 +238,15 @@ RegisterServerEvent('md-drugs:server:stampblue', function(num) else Notifys('You Dont Have Unstamped blue Pills', 'error') end +end) + +AddEventHandler('playerDropped', function() + local src = source + local Player = getPlayer(src) + for k, v in pairs (activePresses) do + if v.ownerid == Player.PlayerData.citizenid then + table.remove(activePresses, k) + AddItem(src, v.get, 1) + end + end end) \ No newline at end of file diff --git a/shared/config.lua b/shared/config.lua index 143acfc..fa577bc 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -2,7 +2,7 @@ Config = {} --Ignore. Config.Target = 'ox' -- qb or ox Config.respawnTime = 600 -- Seconds -Config.Fuel = "ps-fuel" -- type the name of script you use i.e. ps-fuel, cdn-fuel, LegacyFuel +Config.Fuel = "LegacyFuel" -- type the name of script you use i.e. ps-fuel, cdn-fuel, LegacyFuel Config.TierSystem = true -- allows for three tiers of certain drugs ( coke, heroin, crack, lsd) Config.StupidassNewQbItemName = true -- true if you have updated your items.lua from base qb after november 2023 because changing item names this far in a framework is 3 IQ points total Config.RequestModelTime = 30000 -- if you need more time than this, uhhhh wow