From 028c5f771f737618a2d21e4e2e834c1492d65699 Mon Sep 17 00:00:00 2001 From: Mustache Dom <123716453+Mustachedom@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:07:41 -0700 Subject: [PATCH] big update. i prob broke something, let me know in discord --- client/animationsandfunctions.lua | 335 +++++-------------- client/cocaine.lua | 103 +----- client/cornerselling.lua | 151 ++++----- client/deliveries.lua | 373 ++++------------------ client/functions.lua | 300 ++++++++++++++++- client/heroin.lua | 99 ++---- client/lean.lua | 49 ++- client/lsd.lua | 71 ++--- client/mescaline.lua | 18 +- client/meth.lua | 173 +++------- client/oxyruns.lua | 74 ++--- client/shrooms.lua | 17 +- client/target.lua | 313 ++---------------- client/travellingmerchant.lua | 20 +- client/weed.lua | 513 ++++++++++++------------------ client/wholesale.lua | 59 ++-- client/xtc.lua | 43 +-- patchnotes.txt | 60 ++++ readme.md | 3 +- server/cocaine.lua | 129 +++----- server/consumables.lua | 5 +- server/cornerselling.lua | 36 +-- server/crack.lua | 88 ++--- server/deliveries.lua | 218 +++---------- server/functions.lua | 285 +++++++++++++---- server/heroin.lua | 214 +++++-------- server/lean.lua | 42 +-- server/lsd.lua | 186 +++++------ server/mescaline.lua | 35 +- server/meth.lua | 54 ++-- server/oxyruns.lua | 20 +- server/pharma.lua | 70 ++-- server/recipes.lua | 169 ++++++++++ server/shrooms.lua | 16 +- server/travellingmerchant.lua | 12 +- server/weed.lua | 271 ++-------------- server/wholesale.lua | 10 +- server/xtc.lua | 342 +++++++------------- shared/config.lua | 92 +++--- shared/qbdrugsrewrite.lua | 9 +- test.sql | 19 ++ version.txt | 2 +- 42 files changed, 2042 insertions(+), 3056 deletions(-) create mode 100644 server/recipes.lua create mode 100644 test.sql diff --git a/client/animationsandfunctions.lua b/client/animationsandfunctions.lua index f1a89b6..2fb9662 100644 --- a/client/animationsandfunctions.lua +++ b/client/animationsandfunctions.lua @@ -1,8 +1,7 @@ local QBCore = exports['qb-core']:GetCoreObject() local started = nil - -local function loadParticle(dict) + function loadParticle(dict) if not HasNamedPtfxAssetLoaded(dict) then RequestNamedPtfxAsset(dict) end @@ -64,26 +63,11 @@ local scenePos, sceneRot = vector3(1008.734, -3196.646, -39.99), vector3(0.0, 0. local netScene = NetworkCreateSynchronisedScene(scenePos, sceneRot, 2, false, false, 1065353216, 0, 1.3) NetworkAddPedToSynchronisedScene(ped, netScene, animDict, animName, 1.5, -4.0, 1, 16, 1148846080, 0) local objects, sceneObjects = {}, { - { - hash = `w_me_hammer`, - animName = "break_weigh_"..ver.."hammer" - }, - { - hash = `bkr_Prop_Meth_SmashedTray_01_frag_`, - animName = "break_weigh_"..ver.."tray01" - }, - { - hash = `bkr_Prop_Meth_Tray_02a`, - animName = "break_weigh_"..ver.."tray01^1" - }, - { - hash = `bkr_Prop_Meth_Tray_02a`, - animName = "break_weigh_"..ver.."tray01^2" - }, - { - hash = `bkr_Prop_Meth_SmashedTray_01_frag_`, - animName = "break_weigh_"..ver.."tray01^3" - }, + { hash = `w_me_hammer`, animName = "break_weigh_" .. ver .. "hammer"}, + { hash = `bkr_Prop_Meth_SmashedTray_01_frag_`, animName = "break_weigh_"..ver.."tray01"}, + { hash = `bkr_Prop_Meth_Tray_02a`, animName = "break_weigh_"..ver.."tray01^1"}, + { hash = `bkr_Prop_Meth_Tray_02a`, animName = "break_weigh_"..ver.."tray01^2"}, + { hash = `bkr_Prop_Meth_SmashedTray_01_frag_`, animName = "break_weigh_"..ver.."tray01^3"}, } for i=1, #sceneObjects, 1 do local obj = CreateObjectNoOffset(sceneObjects[i].hash, targetPosition, true, true, true) @@ -110,70 +94,28 @@ local ver = "" local scenePos, sceneRot = vector3(1008.734, -3196.646, -39.99), vector3(0.0, 0.0, 1.08) local scenes = { { - { - hash = `bkr_prop_meth_bigbag_04a`, - animName = "break_weigh_"..ver.."box01" - }, - { - hash = `bkr_prop_meth_bigbag_03a`, - animName = "break_weigh_"..ver.."box01^1" - }, - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01" - } + { hash = `bkr_prop_meth_bigbag_04a`, animName = "break_weigh_"..ver.."box01"}, + { hash = `bkr_prop_meth_bigbag_03a`, animName = "break_weigh_"..ver.."box01^1"}, + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01"} }, { - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01^1" - }, - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01^2" - }, - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01^3" - } + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01^1"}, + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01^2"}, + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01^3"} }, { - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01^4" - }, - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01^5" - }, - { - hash = `bkr_prop_meth_openbag_02`, - animName = "break_weigh_"..ver.."methbag01^6" - } + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01^4"}, + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01^5"}, + { hash = `bkr_prop_meth_openbag_02`, animName = "break_weigh_"..ver.."methbag01^6"} }, { - { - hash = `bkr_prop_meth_scoop_01a`, - animName = "break_weigh_"..ver.."scoop" - }, - { - hash = `bkr_prop_coke_scale_01`, - animName = "break_weigh_"..ver.."scale" - }, - { - hash = `bkr_prop_fakeid_penclipboard`, - animName = "break_weigh_"..ver.."pen" - } + { hash = `bkr_prop_meth_scoop_01a`, animName = "break_weigh_"..ver.."scoop"}, + { hash = `bkr_prop_coke_scale_01`, animName = "break_weigh_"..ver.."scale"}, + { hash = `bkr_prop_fakeid_penclipboard`, animName = "break_weigh_"..ver.."pen"} }, { - { - hash = `bkr_prop_fakeid_clipboard_01a`, - animName = "break_weigh_"..ver.."clipboard" - }, - { - hash = `bkr_Prop_Meth_Tray_02a`, - animName = "break_weigh_"..ver.."tray01^5" - } + { hash = `bkr_prop_fakeid_clipboard_01a`, animName = "break_weigh_"..ver.."clipboard"}, + { hash = `bkr_Prop_Meth_Tray_02a`, animName = "break_weigh_"..ver.."tray01^5"} } } local scenesList, entitiesList = {}, {} @@ -237,18 +179,9 @@ function CutCoke() local scenePos, sceneRot = vector3(1090.37+.9, -3193.61-1.68, -39.60), vector3(0.0, 0.0, 0.00) local scenes = { { - { - hash = `bkr_prop_coke_bakingsoda_o`, - animName = "coke_cut_v5_bakingsoda" - }, - { - hash = `prop_cs_credit_card`, - animName = "coke_cut_v5_creditcard" - }, - { - hash = `prop_cs_credit_card`, - animName = "coke_cut_v5_creditcard^1" - } + { hash = `bkr_prop_coke_bakingsoda_o`, animName = "coke_cut_v5_bakingsoda"}, + { hash = `prop_cs_credit_card`, animName = "coke_cut_v5_creditcard"}, + { hash = `prop_cs_credit_card`, animName = "coke_cut_v5_creditcard^1"} }, } @@ -305,52 +238,22 @@ local ver = "" local scenePos, sceneRot = vector3(1090.62+4.3, -3196.2+3, -38.99-1), vector3(360.0, 360.0, 180.08) local scenes = { { - { - hash = `bkr_prop_coke_cutblock_01`, - animName = "break_weigh_"..ver.."box01" - }, - { - hash = `bkr_prop_coke_fullmetalbowl_02`, - animName = "break_weigh_"..ver.."box01^1" - }, - { - hash = `bkr_prop_coke_cutblock_01`, - animName = "break_weigh_"..ver.."methbag01" - } + { hash = `bkr_prop_coke_cutblock_01`, animName = "break_weigh_"..ver.."box01"}, + { hash = `bkr_prop_coke_fullmetalbowl_02`, animName = "break_weigh_"..ver.."box01^1"}, + { hash = `bkr_prop_coke_cutblock_01`, animName = "break_weigh_"..ver.."methbag01"} }, { - { - hash = `xm3_prop_xm3_bag_coke_01a`, - animName = "break_weigh_"..ver.."methbag01^1" - }, - { - hash = `xm3_prop_xm3_bag_coke_01a`, - animName = "break_weigh_"..ver.."methbag01^2" - }, - { - hash = `xm3_prop_xm3_bag_coke_01a`, - animName = "break_weigh_"..ver.."methbag01^3" - } + { hash = `xm3_prop_xm3_bag_coke_01a`, animName = "break_weigh_"..ver.."methbag01^1"}, + { hash = `xm3_prop_xm3_bag_coke_01a`, animName = "break_weigh_"..ver.."methbag01^2"}, + { hash = `xm3_prop_xm3_bag_coke_01a`, animName = "break_weigh_"..ver.."methbag01^3"} }, { - { - hash = `bkr_prop_coke_fullscoop_01a`, - animName = "break_weigh_"..ver.."scoop" - }, - { - hash = `bkr_prop_coke_scale_01`, - animName = "break_weigh_"..ver.."scale" - }, - { - hash = `bkr_prop_fakeid_penclipboard`, - animName = "break_weigh_"..ver.."pen" - } + { hash = `bkr_prop_coke_fullscoop_01a`, animName = "break_weigh_"..ver.."scoop"}, + { hash = `bkr_prop_coke_scale_01`, animName = "break_weigh_"..ver.."scale"}, + { hash = `bkr_prop_fakeid_penclipboard`, animName = "break_weigh_"..ver.."pen"} }, { - { - hash = `bkr_prop_fakeid_clipboard_01a`, - animName = "break_weigh_"..ver.."clipboard" - }, + { hash = `bkr_prop_fakeid_clipboard_01a`, animName = "break_weigh_"..ver.."clipboard"}, } } @@ -477,6 +380,7 @@ function AlienEffect() StopScreenEffect("DrugsMichaelAliensFightOut") end +local hit = 0 function SpawnCarPedChase() local ped = GetEntityCoords(PlayerPedId()) local stoploc = vector3(-1157.63, -3056.71, 13.94) @@ -501,47 +405,21 @@ else repeat -- repeats Wait(1000) only until Wait(1000) until #(GetEntityCoords(driver) - stoploc) < 20.0 or GetEntityHealth(driver) == 0 -- either the distance is within 20 OR the driver is dead + RemoveBlip(leancar) if GetEntityHealth(driver) == 0 then -- once one of those thing ends, the loop breaks and carries on from here - if Config.oxtarget then - local options = { - { - name = 'leancar', - icon = 'fa-solid fa-car', - label = 'Steal From Car', - onSelect = function() - if not minigame(2,8) then return end - TriggerServerEvent('md-drugs:server:givelean') - started = nil - if math.random(1,100) <= 30 then - DeleteVehicle(leancar) - DeleteEntity(driver) - DeleteEntity(pilot2) - end - end, - } - } - exports.ox_target:addLocalEntity(leancar, options) - else - exports['qb-target']:AddTargetEntity(leancar, { - options = { - { - name = 'leancar', - icon = 'fa-solid fa-car', - label = 'Steal From Car', - action = function() - if not minigame(2,8) then return end - TriggerServerEvent('md-drugs:server:givelean') - started = nil - if math.random(1,100) <= 30 then - DeleteVehicle(leancar) - DeleteEntity(driver) - DeleteEntity(pilot2) - end - end, - } - } - }) - end + AddSingleModel(leancar, { name = 'leancar', icon = 'fa-solid fa-car', label = 'Steal From Car', + action = function() + hit = hit + 1 + if not minigame(2,8) then return end + TriggerServerEvent('md-drugs:server:givelean') + started = nil + if math.random(1,100) <= 30 or hit == 4 then + hit = 0 + DeleteVehicle(leancar) + DeleteEntity(driver) + DeleteEntity(pilot2) + end + end}, nil) else repeat -- this second loop is to spawn the helicopter when the truck is in distance Wait(1000) @@ -590,46 +468,21 @@ else Wait(1000) until #(GetEntityCoords(methdriver) - stoploc) < 20.0 or GetEntityHealth(methdriver) == 0 if GetEntityHealth(methdriver) == 0 then - if Config.oxtarget then - local options = { - { - name = 'methcar', - icon = 'fa-solid fa-car', - label = 'Steal From Car', - onSelect = function() - if not minigame(2,8) then return end - TriggerServerEvent('md-drugs:server:givemethingridients') - startedmeth = nil - if math.random(1,100) <= 30 then - DeleteVehicle(methcar) - DeleteEntity(methdriver) - DeleteEntity(methpilot) - end - end, - } - } - exports.ox_target:addLocalEntity(methcar, options) - else - exports['qb-target']:AddTargetEntity(methcar, { - options = { - { - name = 'methcar', - icon = 'fa-solid fa-car', - label = 'Steal From Car', - action = function() - if not minigame(2,8) then return end - TriggerServerEvent('md-drugs:server:givemethingridients') - startedmeth = nil - if math.random(1,100) <= 30 then - DeleteVehicle(methcar) - DeleteEntity(methdriver) - DeleteEntity(methpilot) - end - end, - } - } - }) - end + AddSingleModel(methcar,{ + name = 'methcar', + icon = 'fa-solid fa-car', + label = 'Steal From Car', + action = function() + if not minigame(2,8) then return end + TriggerServerEvent('md-drugs:server:givemethingridients') + startedmeth = nil + if math.random(1,100) <= 30 then + DeleteVehicle(methcar) + DeleteEntity(methdriver) + DeleteEntity(methpilot) + end + end, + }, nil ) else repeat Wait(1000) @@ -653,54 +506,40 @@ end end function SetUpPeds() + AddRelationshipGroup('setups') local ped = GetEntityCoords(PlayerPedId()) -local CokePed = CreatePed(0, "g_m_y_famdnf_01", ped.x+3, ped.y-5, ped.z-1, 90.0, true, true) -local CokePed2 = CreatePed(0,"g_m_y_famdnf_01", ped.x+6, ped.y-10, ped.z-1, 90.0, true, true) -local CokePed3 = CreatePed(0,"g_m_y_famdnf_01", ped.x+-2, ped.y+5, ped.z-1, 90.0, true, true) -local CokePed4 = CreatePed(0,"g_m_y_famdnf_01", ped.x+8, ped.y-12, ped.z-1, 90.0, true, true) -local CokePed5 = CreatePed(0,"g_m_y_famdnf_01", ped.x+5, ped.y-2, ped.z-1, 90.0, true, true) -local CokePed6 = CreatePed(0,"g_m_y_famdnf_01", ped.x+2, ped.y-20, ped.z-1, 90.0, true, true) -local CokePed7 = CreatePed(0,"g_m_y_famdnf_01", ped.x+1, ped.y-10, ped.z-1, 90.0, true, true) -AddRelationshipGroup('setups') -local peds = {CokePed, CokePed2,CokePed3, CokePed4, CokePed5,CokePed6, CokePed7} -for k, v in pairs (ped) do - SetPedRelationshipGroupDefaultHash(v, 'setups') +local peds = { + {x = ped.x+3, y = ped.y-5, z = ped.z-1, }, + {x = ped.x+6, y = ped.y-10, z = ped.z-1,}, + {x = ped.x+-2,y = ped.y+5, z = ped.z-1,}, + {x = ped.x+8, y = ped.y-12, z = ped.z-1,}, + {x = ped.x+5, y = ped.y-2, z = ped.z-1, }, + {x = ped.x+2, y = ped.y-20, z = ped.z-1,}, + {x = ped.x+1, y = ped.y-10, z = ped.z-1,}, +} +for i = 1, #peds do + local k = peds[i] + print(GetPedRelationshipGroupHash(i) ) + i = CreatePed(0, "g_m_y_famdnf_01", k.x, k.y, k.z, 90.0, true, true) + SetPedRelationshipGroupHash(i, 'setups') + GiveWeaponToPed(i, "weapon_pistol", 1, false, true) + TaskCombatPed(i, PlayerPedId(), 0, 16) + SetPedCombatAttributes(i, 46, true) end -SetPedArmour(CokePed, 200) -SetPedCanSwitchWeapon(CokePed, true) -GiveWeaponToPed(CokePed, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed, PlayerPedId(), 0, 16) -GiveWeaponToPed(CokePed2, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed2, PlayerPedId(), 0, 16) -GiveWeaponToPed(CokePed3, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed3, PlayerPedId(), 0, 16) -GiveWeaponToPed(CokePed4, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed4, PlayerPedId(), 0, 16) -GiveWeaponToPed(CokePed5, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed5, PlayerPedId(), 0, 16) -GiveWeaponToPed(CokePed6, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed6, PlayerPedId(), 0, 16) -GiveWeaponToPed(CokePed7, "weapon_pistol", 1, false, true) -TaskCombatPed(CokePed7, PlayerPedId(), 0, 16) -SetPedCombatAttributes(CokePed, 46, true) -SetPedCombatAttributes(CokePed2, 46, true) -SetPedCombatAttributes(CokePed3, 46, true) -SetPedCombatAttributes(CokePed4, 46, true) -SetPedCombatAttributes(CokePed5, 46, true) -SetPedCombatAttributes(CokePed6, 46, true) -SetPedCombatAttributes(CokePed7, 46, true) + end RegisterCommand('DrugRep', function() if not Config.TierSystem then return end + local rep = lib.callback.await('md-drugs:server:GetRep', false) lib.registerContext({ id = 'DrugRep', title = 'Drug Reputation', options = { - {icon = "fa-solid fa-face-flushed", title = 'Cocaine: '..QBCore.Functions.GetPlayerData().metadata.coke}, - {icon = "fa-solid fa-syringe", title = 'Heroin: '..QBCore.Functions.GetPlayerData().metadata.heroin}, - {icon = "fa-solid fa-vial", title = 'LSD: '..QBCore.Functions.GetPlayerData().metadata.lsd}, - {icon = "fa-solid fa-plug", title = 'Dealer: '..QBCore.Functions.GetPlayerData().metadata.dealerrep}, + {icon = "fa-solid fa-face-flushed", title = 'Cocaine: '..rep.coke}, + {icon = "fa-solid fa-syringe", title = 'Heroin: '..rep.heroin}, + {icon = "fa-solid fa-vial", title = 'LSD: '..rep.lsd}, + {icon = "fa-solid fa-plug", title = 'Dealer: '..rep.dealerrep}, } }) lib.showContext('DrugRep') diff --git a/client/cocaine.lua b/client/cocaine.lua index 1a82378..66ebd51 100644 --- a/client/cocaine.lua +++ b/client/cocaine.lua @@ -14,31 +14,8 @@ RegisterNetEvent('coke:respawnCane', function(loc) local hash = GetHashKey(v.model) if not CocaPlant[loc] then CocaPlant[loc] = CreateObject(hash, v.location, false, true, true) - Freeze(CocaPlant[loc], true, v.heading) - local options = { - { - icon = "fas fa-hand", - label = "pick Cocaine", - action = function() - if not pick(loc) then return end - end - } - } - local optionsox = { - { - icon = "fas fa-hand", - label = "pick Cocaine", - distance = 2.5, - onSelect = function() - if not pick(loc) then return end - end - } - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(CocaPlant[loc], optionsox) - else - exports['qb-target']:AddTargetEntity(CocaPlant[loc], {options = options, distance = 2.5}) - end + Freeze(CocaPlant[loc], true, v.heading) + AddSingleModel(CocaPlant[loc], {icon = 'fas fa-hand', label = 'Pick Cocaine', action = function() if not pick(loc) then return end end}, loc) end end) @@ -54,32 +31,9 @@ RegisterNetEvent("coke:init", function() if not v.taken then CocaPlant[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true) Freeze(CocaPlant[k], true, v.heading) - local options = { - { - icon = "fas fa-hand", - label = "pick Cocaine", - action = function() - if not pick(k) then return end - end - } - } - local optionsox = { - { - icon = "fas fa-hand", - label = "pick Cocaine", - distance = 2.5, - onSelect = function() - if not pick(k) then return end - end - } - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(CocaPlant[k], optionsox) - else - exports['qb-target']:AddTargetEntity(CocaPlant[k], {options = options, distance = 2.5}) + AddSingleModel(CocaPlant[k], {icon = 'fas fa-hand', label = 'Pick Cocaine', action = function() if not pick(k) then return end end}, k) end end - end end) AddEventHandler('onResourceStart', function(resource) @@ -137,50 +91,13 @@ RegisterNetEvent("md-drugs:client:bagcoke", function() end) CreateThread(function() - local options = { - { type = "client", event = "md-drugs:client:cutcokeone", icon = "fas fa-sign-in-alt", label = "cut up", canInteract = function() - if cuttingcoke == nil and baggingcoke == nil then return true end - end - }, - } - local options2 = { - { type = "client", event = "md-drugs:client:bagcoke", icon = "fas fa-sign-in-alt", label = "bagging", canInteract = function() - if baggingcoke == nil and cuttingcoke == nil then return true end end }, } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = vector3(1093.17, -3195.74, -39.19 -1), size = vec3(1,1,1), options = options}) - exports.ox_target:addBoxZone({coords = vector3(1093.17, -3195.74, -39.19 -1), size = vec3(1,1,1), options = options2}) - else - exports['qb-target']:AddBoxZone("cutcokepowder",vector3(1093.17, -3195.74, -39.19 -1),1.5, 1.75, {name = "cutcokepowder", minZ = -40.0,maxZ = -38.0,}, { options = options, distance = 2.0 }) - exports['qb-target']:AddBoxZone("bagcokepowder",vector3(1090.29, -3195.66, -39.13 - 1),1.5, 1.75, {name = "bagcokepowder", minZ = -40, maxZ = -38,}, {options = options2, distance = 2.0}) - end if Config.FancyCokeAnims == false then - for k, v in pairs (Config.CuttingCoke) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:cutcokeone", icon = "fas fa-sign-in-alt", label = "Cut Coke", data = k, distance = 2.0, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - }, - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("cutcoke"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="cutcoke"..k, heading = 156.0,minZ = v.loc.z-1, maxZ = v.loc.z+1, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.BaggingCoke) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:bagcoke", icon = "fas fa-sign-in-alt", label = "Bag Coke", data = k, distance = 2.0, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - }, - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("bagcoke"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="bagcoke"..k, heading = 156.0,minZ = v.loc.z-1, maxZ = v.loc.z+1, }, {options = options, distance = 1.5}) - end - end + AddBoxZoneMulti('cuttcoke', Config.CuttingCoke, { type = "client", event = "md-drugs:client:cutcokeone", icon = "fas fa-sign-in-alt", label = "Cut Coke"}) + AddBoxZoneMulti('baggcoke', Config.BaggingCoke, { type = "client", event = "md-drugs:client:bagcoke", icon = "fas fa-sign-in-alt", label = "Bag Coke"}) + else + AddBoxZoneSingle('cutcoke', vector3(1093.17, -3195.74, -39.19), + { type = "client", event = "md-drugs:client:cutcokeone", icon = "fas fa-sign-in-alt", label = "cut up", canInteract = function()if cuttingcoke == nil and baggingcoke == nil then return true end end }) + AddBoxZoneSingle('bagcokepowder', vector3(1090.29, -3195.66, -39.13), + { type = "client", event = "md-drugs:client:bagcoke", icon = "fas fa-sign-in-alt", label = "bagging", canInteract = function() if baggingcoke == nil and cuttingcoke == nil then return true end end }) end end) diff --git a/client/cornerselling.lua b/client/cornerselling.lua index 870e813..d862af3 100644 --- a/client/cornerselling.lua +++ b/client/cornerselling.lua @@ -1,11 +1,47 @@ local QBCore = exports['qb-core']:GetCoreObject() local sell = false +local sold = false +local targbusy = false + +local function sellDrug(item, amount, price, targ) + PoliceCall(20) + targbusy = true + if IsPedInAnyVehicle(PlayerPedId(), true) then + Notify('STRANGER DANGER, I WONT GET IN THE CAR WITH YOU', 'error') + FreezeEntityPosition(targ, false) + ClearPedTasks(targ) + Wait(10000) + DeletePed(targ) + targbusy = false + sold = true + sell = false + return end + if not progressbar('Selling ' .. GetLabel(item) .. '!', 4000, 'uncuff') then return end + TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, amount, price) + FreezeEntityPosition(targ, false) + ClearPedTasks(targ) + Wait(10000) + DeletePed(targ) + targbusy = false + sold = true + end + +local function deny(targ) + PoliceCall(20) + targbusy = true + if not progressbar('Telling This Dumbass To Leave!', 4000, 'argue5') then return end + FreezeEntityPosition(targ, false) + ClearPedTasks(targ) + Wait(10000) + DeletePed(targ) + targbusy = false + sold = true +end function Cornersell() local targ = lib.GetClosestPed(GetEntityCoords(PlayerPedId()), 8) if targ == nil then return end - if IsPedInAnyVehicle(targ, false) or GetEntityHealth(targ) == 0 then return end - local sold = false + if IsPedInAnyVehicle(targ, false) or GetEntityHealth(targ) == 0 or not IsPedHuman(targ) then return end TaskGoToCoordAnyMeans(targ, GetEntityCoords(PlayerPedId()), 1.0, 0, 0, 0, 0) repeat Wait(1000) @@ -13,110 +49,31 @@ function Cornersell() lib.requestAnimDict("rcmme_tracey1") TaskStartScenarioInPlace(targ, "WORLD_HUMAN_STAND_IMPATIENT_UPRIGHT", 0, false) FreezeEntityPosition(targ, true) - local item, amount = lib.callback.await('md-drugs:server:cornerselling:getAvailableDrugs', false) + local item, amount, price = lib.callback.await('md-drugs:server:cornerselling:getAvailableDrugs', false) if item == 'nothing' then Notify(' You Aint Got Shit', 'error') sell = false FreezeEntityPosition(targ, false) ClearPedTasks(targ) return false end - local bagAmount = math.random(1, amount) - if bagAmount > 15 then bagAmount = math.random(1,15) end - local table = QBConfig.DrugsPrice[item] - local price = math.random(table['min'], table['max'] ) * bagAmount - local targbusy = false - local options = { - { label = 'Sell ' .. bagAmount .. ' Of ' .. GetLabel(item) .. ' For $' .. price .. '!', icon = "fas fa-eye", - onSelect = function() - PoliceCall(20) - targbusy = true - if IsPedInAnyVehicle(PlayerPedId(), true) then - Notify('STRANGER DANGER, I WONT GET IN THE CAR WITH YOU', 'error') - FreezeEntityPosition(targ, false) - ClearPedTasks(targ) - Wait(10000) - DeletePed(targ) - targbusy = false - sold = true - sell = false - return end - if not progressbar('Selling ' .. GetLabel(item) .. '!', 4000, 'uncuff') then return end - TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, bagAmount, price) - FreezeEntityPosition(targ, false) - ClearPedTasks(targ) - Wait(10000) - DeletePed(targ) - targbusy = false - sold = true - - end, - canInteract = function() - if not targbusy then return true end end, - distance = 2.0 - }, - { label = 'Deny Price', icon = "fas fa-eye", - onSelect = function() - PoliceCall(20) - targbusy = true - if not progressbar('Telling This Dumbass To Leave!', 4000, 'argue5') then return end - FreezeEntityPosition(targ, false) - ClearPedTasks(targ) - Wait(10000) - DeletePed(targ) - targbusy = false - sold = true - end, - canInteract = function() - if not targbusy then return true end end, - distance = 2.0 - }, - } - local optionsqb = { - { label = 'Sell ' .. bagAmount .. ' Of ' .. GetLabel(item) .. ' For $' .. price .. '!', icon = "fas fa-eye", + local options = { + { label = 'Sell ' .. amount .. ' Of ' .. GetLabel(item) .. ' For $' .. price .. '!', icon = "fas fa-eye", action = function() - PoliceCall(20) - targbusy = true - if IsPedInAnyVehicle(PlayerPedId(), true) then - Notify('STRANGER DANGER, I WONT GET IN THE CAR WITH YOU', 'error') - FreezeEntityPosition(targ, false) - ClearPedTasks(targ) - Wait(10000) - DeletePed(targ) - targbusy = false - sold = true - sell = false - return end - if not progressbar('Selling ' .. GetLabel(item) .. '!', 4000, 'uncuff') then return end - TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, bagAmount, price) - FreezeEntityPosition(targ, false) - ClearPedTasks(targ) - Wait(10000) - DeletePed(targ) - targbusy = false - sold = true - + sellDrug(item, amount, price, targ) end, - canInteract = function() - if not targbusy then return true end end, - distance = 2.0 + onSelect = function() + sellDrug(item, amount, price, targ) + end, + canInteract = function() + if not targbusy then return true end end, }, { label = 'Deny Price', icon = "fas fa-eye", action = function() - PoliceCall(20) - targbusy = true - if not progressbar('Telling This Dumbass To Leave!', 4000, 'argue5') then return end - FreezeEntityPosition(targ, false) - ClearPedTasks(targ) - Wait(10000) - DeletePed(targ) - targbusy = false - sold = true + deny(targ) end, + onSelect = function() + deny(targ) + end, canInteract = function() if not targbusy then return true end end, - distance = 2.0 }, - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(targ, options) - else - exports['qb-target']:AddTargetEntity(targ, { options = optionsqb, distance = 2.0}) - end + } + AddMultiModel(targ, options, nil) repeat Wait(1000) until sold @@ -125,7 +82,7 @@ end RegisterNetEvent('md-drugs:client:cornerselling', function() if not GetCops(QBConfig.MinimumDrugSalePolice) then return end - local item, amount = lib.callback.await('md-drugs:server:cornerselling:getAvailableDrugs', false) + local item, amount, price = lib.callback.await('md-drugs:server:cornerselling:getAvailableDrugs', false) if item ~= 'nothing' then if sell then Notify('Lazy Ass Cant Even Sell Drugs', 'error') diff --git a/client/deliveries.lua b/client/deliveries.lua index 961a8ba..fb3056f 100644 --- a/client/deliveries.lua +++ b/client/deliveries.lua @@ -1,40 +1,5 @@ local QBCore = exports['qb-core']:GetCoreObject() -local currentDealer = nil -local dealerIsHome = false -local waitingDelivery = nil -local activeDelivery = nil -local deliveryTimeout = 0 -local waitingKeyPress = false -local dealerCombo = nil -local drugDeliveryZone - --- Handlers - -AddStateBagChangeHandler('isLoggedIn', nil, function(_, _, value) - if value then - QBCore.Functions.TriggerCallback('md-drugs:server:RequestConfig', function(DealerConfig) - QBConfig.Dealers = DealerConfig - end) - Wait(1000) - InitZones() - else - if dealerCombo then dealerCombo:destroy() end - end -end) - --- Functions - -local function GetClosestDealer() - local ped = PlayerPedId() - local pCoords = GetEntityCoords(ped) - for k, v in pairs(QBConfig.Dealers) do - local dealerCoords = vector3(v.coords.x, v.coords.y, v.coords.z) - if #(pCoords - dealerCoords) < 2.0 then - currentDealer = k - break - end - end -end +local isActive = false RegisterNetEvent('md-drugs:client:opendealermenu', function() local dealermenu = {} if Config.StupidassNewQbItemName then @@ -80,281 +45,75 @@ RegisterNetEvent('md-drugs:client:opendealermenu', function() end lib.showContext('dealermenu') end) -local function RandomDeliveryItemOnRep() - local myRep = QBCore.Functions.GetPlayerData().metadata["dealerrep"] - local availableItems = {} - for k, _ in pairs(QBConfig.DeliveryItems) do - if QBConfig.DeliveryItems[k]["minrep"] <= myRep then - availableItems[#availableItems+1] = k - end - end - return availableItems[math.random(1, #availableItems)] -end -local function RequestDelivery() - if not waitingDelivery then - GetClosestDealer() - - local amount = math.random(1, 3) - local item = RandomDeliveryItemOnRep() - - Notify(Lang.Delivery.search, 'success') - if Config.NearbyDeliveries == true then - local playerPed = PlayerPedId() - local playerCoords = GetEntityCoords(playerPed) - local nearbyLocations = {} - -- Filter out the nearby locations - for _, location in ipairs(Config.DeliveryLocations) do - local distance = #(playerCoords - location.coords) - if distance <= Config.DeliveryWithin then - nearbyLocations[#nearbyLocations + 1] = location - end - end - - -- Select a random location from the nearby locations - if #nearbyLocations > 0 then - local selectedLocation = nearbyLocations[math.random(1, #nearbyLocations)] - waitingDelivery = { - ["coords"] = selectedLocation.coords, - ["locationLabel"] = selectedLocation.label, - ["amount"] = amount, - ["dealer"] = currentDealer, - ["itemData"] = Config.DeliveryItems[item], - ["item"] = item - } - else - Notify(Lang.Delivery.none, 'error') - - end - else - local location = math.random(1, #QBConfig.DeliveryLocations) - - waitingDelivery = { - ["coords"] = QBConfig.DeliveryLocations[location]["coords"], - ["locationLabel"] = QBConfig.DeliveryLocations[location]["label"], - ["amount"] = amount, - ["dealer"] = currentDealer, - ["itemData"] = QBConfig.DeliveryItems[item], - ["item"] = item - } - if QBConfig.Debug == true then - print(QBConfig.DeliveryLocations[location]["coords"]) - print(QBConfig.DeliveryLocations[location]["label"]) - end - end - - TriggerServerEvent('md-drugs:server:giveDeliveryItems', waitingDelivery) - SetTimeout(2000, function() - TriggerServerEvent('qb-phone:server:sendNewMail', { - sender = QBConfig.Dealers[currentDealer]["name"], - subject = "Delivery Location", - message = "Deliver This For Me", - - }) - end) - TriggerEvent("md-drugs:client:setLocation",waitingDelivery) - else - Notify(Lang.Delivery.busy, 'error') - end -end - -local function DeliveryTimer() - CreateThread(function() - while deliveryTimeout - 1 > 0 do - deliveryTimeout = deliveryTimeout - 1 - Wait(1000) - end - deliveryTimeout = 0 - end) -end - - - -local function DeliverStuff() - if deliveryTimeout > 0 then - Wait(500) - TriggerEvent('animations:client:EmoteCommandStart', {'uncuff'}) - PoliceCall(20) - progressbar(Lang.Delivery.pack, 4000, 'uncuff') - TriggerServerEvent('md-drugs:server:successDelivery', activeDelivery, true) - activeDelivery = nil - exports['qb-target']:RemoveZone('drugDeliveryZone') - ClearPedTasks(PlayerPedId()) - else - TriggerServerEvent('md-drugs:server:successDelivery', activeDelivery, false) - end - deliveryTimeout = 0 -end - -local function SetMapBlip(x, y) - SetNewWaypoint(x, y) - Notify(Lang.Delivery.found, 'success'); -end - - - - -function InitZones() - if next(QBConfig.Dealers) == nil then return end - - for k,v in pairs(QBConfig.Dealers) do +CreateThread(function() + local dealer = {} + local getDealers = lib.callback.await('md-drugs:server:getDealers', false) + for k,v in pairs(getDealers) do local Ped = "g_m_y_famdnf_01" - RequestModel(Ped) - while not HasModelLoaded(Ped) do - Wait(0) - end - testdealer = CreatePed(0, Ped,v.coords.x,v.coords.y,v.coords.z-1, 90.0, false, false) - Freeze(testdealer, true, 90) - exports["qb-target"]:AddBoxZone("dealer_"..k, vector3(v.coords.x, v.coords.y, v.coords.z), 1.5, 1.5, { - name = "dealer_"..k, - heading = v.heading, - minZ = v.coords.z - 1, - maxZ = v.coords.z + 1, - debugPoly = false, - }, { - options = { - { - icon = 'fas fa-user-secret', - label = "Deliver", - action = function() - RequestDelivery() - end, - canInteract = function() - GetClosestDealer() - local hours = GetClockHours() - local min = QBConfig.Dealers[currentDealer]["time"]["min"] - local max = QBConfig.Dealers[currentDealer]["time"]["max"] - if max < min then - if hours <= max then - if not waitingDelivery then - return true - end - elseif hours >= min then - if not waitingDelivery then - return true - end - end - else - if hours >= min and hours <= max then - if not waitingDelivery then - return true - end - end - end - end - }, - { - icon = 'fas fa-user-secret', - label = "Open Shop", - action = function() - TriggerEvent('md-drugs:client:opendealermenu') - end, - canInteract = function() - GetClosestDealer() - local hours = GetClockHours() - local min = QBConfig.Dealers[currentDealer]["time"]["min"] - local max = QBConfig.Dealers[currentDealer]["time"]["max"] - if max < min then - if hours <= max then - return true - elseif hours >= min then - return true - end - else - if hours >= min and hours <= max then - return true - end - end - end - } - }, - distance = 1.5 - }) + lib.requestModel(Ped, Config.RequestModelTime) + local loc = json.decode(v.coords) + dealer[k] = CreatePed(0, Ped,loc.x,loc.y, loc.z-1, loc.h, false, false) + Freeze(dealer[k], true, loc.h) + local options = { + { + icon = 'fas fa-user-secret', + label = "Deliver For " .. v.name, + action = function() + local bool, item, amount, coords = lib.callback.await('md-drugs:server:GetDeliveryItem', false, k) + if bool then + Email('Not A Drug Dealer', 'Hurry Up And Get The Package To The Buyer', 'I Swear To God If It Doesnt Get There I Will Tell Your Mom You Said Fuck Just Bring ' .. amount .. ' Of '.. GetLabel(item) .. '!' ) + TriggerEvent('md-drugs:client:setLocation', {bool = bool, item = item, amount = amount, coords = coords}) + end + end, + onSelect = function() + local bool, item, amount, coords = lib.callback.await('md-drugs:server:GetDeliveryItem', false, k) + if item then + TriggerEvent('md-drugs:client:setLocation', {bool = bool, item = item, amount = amount, coords = coords}) + Email('Not A Drug Dealer', 'Hurry Up And Get The Package To The Buyer', 'I Swear To God If It Doesnt Get There I Will Tell Your Mom You Said Fuck Just Bring ' .. amount .. ' Of '.. GetLabel(item) .. '!' ) + end + end + }, + { + icon = 'fas fa-user-secret', + label = "Open " .. v.name .. "'s Shop", + action = function() + TriggerEvent('md-drugs:client:opendealermenu') + end, + onSelect = function() + TriggerEvent('md-drugs:client:opendealermenu') + end + + } + } + AddMultiModel(dealer[k], options) end - -end - --- Events - -RegisterNetEvent('md-drugs:client:RefreshDealers', function(DealerData) - if dealerCombo then dealerCombo:destroy() end - QBConfig.Dealers = DealerData - Wait(1000) - InitZones() end) -RegisterNetEvent('md-drugs:client:updateDealerItems', function(itemData, amount) - TriggerServerEvent('md-drugs:server:updateDealerItems', itemData, amount, currentDealer) -end) - -RegisterNetEvent('md-drugs:client:setDealerItems', function(itemData, amount, dealer) - QBConfig.Dealers[dealer]["products"][itemData.slot].amount = QBConfig.Dealers[dealer]["products"][itemData.slot].amount - amount -end) - -RegisterNetEvent('md-drugs:client:setLocation', function(locationData) - if activeDelivery then - SetMapBlip(activeDelivery["coords"]["x"], activeDelivery["coords"]["y"]) - Notify(Lang.Delivery.already, 'error') +RegisterNetEvent('md-drugs:client:setLocation', function(data) + local coord = json.decode(data.coords) + if isActive then + Blip(vector3(coord.x, coord.y, coord.z), 'Drop Off') return end - activeDelivery = locationData - deliveryTimeout = 300 - DeliveryTimer() - SetMapBlip(activeDelivery["coords"].x, activeDelivery["coords"].y) - local Ped = "g_m_y_famdnf_01" - RequestModel(Ped) - while not HasModelLoaded(Ped) do - Wait(0) - end - - Buyer = CreatePed(0, Ped,activeDelivery["coords"].x, activeDelivery["coords"].y, activeDelivery["coords"].z-1, 180.0, false, false) - Freeze(Buyer, true, 180) - exports['qb-target']:AddTargetEntity(Buyer, { - options = { - { - icon = 'fas fa-user-secret', - label = "Hand Off", - action = function() - DeliverStuff() - Wait(4000) - DeleteEntity(Buyer) - waitingDelivery = nil - end, - canInteract = function() - if waitingDelivery then - return true - end - end - } - }, - distance = 1.5 - }) - -end) - -RegisterNetEvent('md-drugs:client:sendDeliveryMail', function(type, deliveryData) - if type == 'perfect' then - TriggerServerEvent('qb-phone:server:sendNewMail', { - sender = QBConfig.Dealers[deliveryData["dealer"]]["name"], - subject = "Delivery", - message = "You did it" - }) - elseif type == 'bad' then - TriggerServerEvent('qb-phone:server:sendNewMail', { - sender = QBConfig.Dealers[deliveryData["dealer"]]["name"], - subject = "Delivery", - message = "You Fucked Me Over" - }) - elseif type == 'late' then - TriggerServerEvent('qb-phone:server:sendNewMail', { - sender = QBConfig.Dealers[deliveryData["dealer"]]["name"], - subject = "Delivery", - message = "Better Late Than Dead" - }) - end -end) - -RegisterCommand('checkrep', function() - local drugrep = QBCore.Functions.GetPlayerData().metadata["dealerrep"] - Notify(Lang.Delivery.checkrep..drugrep) -end, false) + isActive = true + Blip(vector3(coord.x, coord.y, coord.z), 'Drop Off') + Buyer = CreatePed(0, "g_m_y_famdnf_01",coord.x, coord.y, coord.z-1, 180.0, false, false) + Freeze(Buyer, true, 180) + AddSingleModel(Buyer, { + icon = 'fas fa-user-secret', + label = "Hand Off", + action = function() + if not progressbar('Delivering The Package', 4000, 'uncuff') then return end + isActive = false + DeletePed(Buyer) + RemoveBlip(deliveryBlip) + TriggerServerEvent('md-drugs:server:giveDeliveryItems', data.item, data.amount) + end, + canInteract = function() + if isActive then + return true + end + end + }, nil) +end) \ No newline at end of file diff --git a/client/functions.lua b/client/functions.lua index 2f72fac..3b94d99 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -49,27 +49,59 @@ function progressbar(text, time, anim) until cancelled or test if test then return true end else - print"dude, it literally tells you what you need to set it as in the config" + print"^1 SCRIPT ERROR: Md-DRUGS set your progressbar with one of the options!" end end function minigame(num1, num2) - local check + local game = Config.Minigames if minigametype == 'ps' then + local check exports['ps-ui']:Circle(function(success) check = success - end, num1, num2) + end, game['ps'].amount, game['ps'].speed) return check elseif minigametype == 'ox' then - num1 = 'easy' - if num2 <= 6 then num2 = 'hard' elseif num2 >= 7 and num2 <= 12 then num2 = 'medium' else num2 = 'easy' end - local success = lib.skillCheck({num1, num2}, {'1', '2', '3', '4'}) - return success - elseif minigametype == 'none' then - return true - else - print"dude, it literally tells you what you need to set it as in the config" + local success = lib.skillCheck(game['ox'], {'1', '2', '3', '4'}) + return success + elseif minigametype == 'blcirprog' then + local success = exports.bl_ui:CircleProgress(game['blcirprog'].amount, game['blcirprog'].speed) + return success + elseif minigametype == 'blprog' then + local success = exports.bl_ui:Progress(game['blprog'].amount, game['blprog'].speed) + return success + elseif minigametype == 'blkeyspam' then + local success = exports.bl_ui:KeySpam(game['blkeyspam'].amount, game['blprog'].difficulty) + return success + elseif minigametype == 'blkeycircle' then + local success = exports.bl_ui:KeyCircle(game['blkeycircle'].amount, game['blkeycircle'].difficulty, game['blkeycircle'].keynumbers) + return success + elseif minigametype == 'blnumberslide' then + local success = exports.bl_ui:NumberSlide(game['blnumberslide'].amount, game['blnumberslide'].difficulty, game['blnumberslide'].keynumbers) + return success + elseif minigametype == 'blrapidlines' then + local success = exports.bl_ui:RapidLines(game['blrapidlines'].amount, game['blrapidlines'].difficulty, game['blrapidlines'].numberofline) + return success + elseif minigametype == 'blcircleshake' then + local success = exports.bl_ui:CircleShake(game['blcircleshake'].amount, game['blcircleshake'].difficulty, game['blcircleshake'].stages) + return success + elseif minigametype == 'glpath' then + exports["glow_minigames"]:StartMinigame(function(success) + if success then return true else return false end + end, "path", game['glpath']) + elseif minigametype == 'glspot' then + exports["glow_minigames"]:StartMinigame(function(success) + if success then return true else return false end + end, "spot", game['glspot']) + elseif minigametype == 'glmath' then + exports["glow_minigames"]:StartMinigame(function(success) + if success then return true else return false end + end, "math", game['glmath']) + elseif minigametype == 'none' then + return true + else + print"^1 SCRIPT ERROR: Md-DRUGS set your minigame with one of the options!" end end @@ -82,8 +114,8 @@ end elseif notifytype == 'okok' then exports['okokNotify']:Alert('', text, 4000, type, false) else - print"dude, it literally tells you what you need to set it as in the config" - end + print"^1 SCRIPT ERROR: Md-DRUGS set your notification with one of the options!" + end end function GetImage(img) @@ -126,13 +158,32 @@ end function ItemCheck(item) local success if GetResourceState('ox_inventory') == 'started' then - if exports.ox_inventory:GetItemCount(item) >= 1 then return true else Notify('You Need ' .. GetLabel(item) .. " !", 'error') end + if exports.ox_inventory:GetItemCount(item) >= 1 then return true else Notify('You Need ' .. GetLabel(item) .. " !", 'error') return false end else if QBCore.Shared.Items[item] == nil then print("There Is No " .. item .. " In Your QB Items.lua") return end - if QBCore.Functions.HasItem(item) then success = item return success else Notify('You Need ' .. QBCore.Shared.Items[item].label .. " !", 'error') end + if QBCore.Functions.HasItem(item) then return true else Notify('You Need ' .. QBCore.Shared.Items[item].label .. " !", 'error') return false end end end +function ItemCheckMulti(item) + local need = 0 + local has = 0 + for k,v in pairs (item) do + need = need + 1 + if GetResourceState('ox_inventory') == 'started' then + if exports.ox_inventory:GetItemCount(v) >= 1 then has = has + 1 else Notify('You Need ' .. GetLabel(v) .. " !", 'error') end + else + if QBCore.Shared.Items[v] == nil then print("There Is No " .. item .. " In Your QB Items.lua") return end + if QBCore.Functions.HasItem(v) then has = has + 1 else Notify('You Need ' .. QBCore.Shared.Items[v].label .. " !", 'error') end + end + end + if need == has then + return true + else + return false + end +end + function Email(sender, subject, message) if Config.Phone == 'yflip' then local receiver = GetPlayerServerId(PlayerId()) @@ -212,4 +263,221 @@ function Freeze(entity, toggle, head) FreezeEntityPosition(entity, toggle) SetEntityHeading(entity, head) SetBlockingOfNonTemporaryEvents(entity, toggle) -end \ No newline at end of file +end + +function tele(coords) + DoScreenFadeOut(500) + Wait(1000) + SetEntityCoords(PlayerPedId(),coords.x, coords.y, coords.z) + Wait(1000) + DoScreenFadeIn(500) +end + +function Blip(entity, text) + local deliveryBlip = AddBlipForCoord(entity) + SetBlipSprite(deliveryBlip, 1) + SetBlipDisplay(deliveryBlip, 2) + SetBlipScale(deliveryBlip, 1.0) + SetBlipAsShortRange(deliveryBlip, false) + SetBlipColour(deliveryBlip, 27) + BeginTextCommandSetBlipName("STRING") + AddTextComponentSubstringPlayerName(text) + EndTextCommandSetBlipName(deliveryBlip) + SetBlipRoute(deliveryBlip, true) +end + +function RemoveBlips() + RemoveBlip(deliveryBlip) +end + +function AddBoxZoneSingle(name, loc, data) + if Config.Target == 'qb' then + exports['qb-target']:AddBoxZone(name, loc, 1.5, 1.75, {name = name, minZ = loc.z-1,maxZ = loc.z +1}, + { options = { + { + type = data.type or nil, + event = data.event or nil, + action = data.action or nil, + icon = data.icon, + label = data.label, + data = data.data, + canInteract = data.canInteract, + } + }, + distance = 2.0 + }) + elseif Config.Target == 'ox' then + exports.ox_target:addBoxZone({coords = loc, size = vec3(1,1,1), options = { + { + type = data.type or nil, + event = data.event or nil, + onSelect = data.action or nil, + distance = 2.5, + icon = data.icon, + label = data.label, + data = data.data, + canInteract = data.canInteract, + } + }, }) + end +end + +function AddBoxZoneMulti(name, table, data) + for k, v in pairs (table) do + if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end + if Config.Target == 'qb' then + exports['qb-target']:AddBoxZone(name .. k, v.loc, 1.5, 1.75, {name = name..k, minZ = v.loc.z-1.50,maxZ = v.loc.z +1.5}, + { options = { + { + type = data.type or nil, + event = data.event or nil, + action = data.action or nil, + icon = data.icon, + label = data.label, + data = k, + canInteract = data.canInteract or function() + if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end + } + }, + distance = 2.5 + }) + elseif Config.Target == 'ox' then + exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1), options = { + { + type = data.type or nil, + event = data.event or nil, + onSelect = data.action or nil, + icon = data.icon, + label = data.label, + data = k, + distance = 2.5, + canInteract = data.canInteract or function() + if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end + } + }, }) + end + end +end + +function AddSingleModel(model, data, num) + if Config.Target == 'qb' then + exports['qb-target']:AddTargetEntity(model, {options = { + {icon = data.icon, label = data.label, event = data.event or nil, action = data.action or nil, data = num } + }, distance = 2.5}) + elseif Config.Target == 'ox' then + exports.ox_target:addLocalEntity(model, {icon = data.icon, label = data.label, event = data.event or nil, onSelect = data.action or nil, data = num, distance = 2.5 }) + end +end + +function AddMultiModel(model, data, num) + if Config.Target == 'qb' then + exports['qb-target']:AddTargetEntity(model, {options = data, distance = 2.5}) + elseif Config.Target == 'ox' then + exports.ox_target:addLocalEntity(model, data) + end +end + +local created = false +local heading = 180.0 +function StartRay() + local run = true + local pedcoord = GetEntityCoords(PlayerPedId()) + local table = CreateObject('v_ret_ml_tablea', pedcoord.x, pedcoord.y, pedcoord.z+1, heading, false, false) + repeat + local hit, entityHit, endCoords, surfaceNormal, matHash = lib.raycast.cam(511, 4, 10) + if not created then + created = true + lib.showTextUI([[[E] To Place + [DEL] To Cancel + [<-] To Move Left + [->] To Move Right]]) + else + SetEntityCoords(table, endCoords.x, endCoords.y, endCoords.z+1) + SetEntityHeading(table, heading) + SetEntityCollision(table, false, false) + SetEntityAlpha(table, 100) + end + if IsControlPressed(0, 174) then + heading = heading - 2 + end + if IsControlPressed(0, 175) then + heading = heading + 2 + end + if IsControlPressed(0, 38) then + lib.hideTextUI() + run = false + DeleteObject(table) + created = false + return endCoords, heading + end + + if IsControlPressed(0, 178) then + lib.hideTextUI() + run = false + created = false + DeleteObject(table) + return nil, nil + end + Wait(0) + until run == false +end + +function StartRay2() + local run = true + local pedcoord = GetEntityCoords(PlayerPedId()) + local table = CreateObject('bkr_prop_coke_press_01aa', pedcoord.x, pedcoord.y, pedcoord.z+1, heading, false, false) + repeat + local hit, entityHit, endCoords, surfaceNormal, matHash = lib.raycast.cam(511, 4, 10) + if not created then + created = true + lib.showTextUI([[[E] To Place + [DEL] To Cancel + [<-] To Move Left + [->] To Move Right]]) + else + SetEntityCoords(table, endCoords.x, endCoords.y, endCoords.z+1) + SetEntityHeading(table, heading) + SetEntityCollision(table, false, false) + SetEntityAlpha(table, 100) + end + if IsControlPressed(0, 174) then + heading = heading - 2 + end + if IsControlPressed(0, 175) then + heading = heading + 2 + end + if IsControlPressed(0, 38) then + lib.hideTextUI() + run = false + DeleteObject(table) + created = false + return endCoords, heading + end + + if IsControlPressed(0, 178) then + lib.hideTextUI() + run = false + created = false + DeleteObject(table) + return nil, nil + end + Wait(0) + until run == false +end + + +RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() + Wait(3000) + local check = lib.callback.await('md-drugs:server:GetRep', false) + + return +end) +local active = false +RegisterNetEvent('md-drugs:client:minusTier', function(data) + if active then return end + if not data then return end + active = true + if not progressbar('Cutting This ' ..GetLabel(data.item) .. ' More', 4000, 'uncuff') then return end + TriggerServerEvent('md-drugs:server:AddMas', data) + active = false +end) \ No newline at end of file diff --git a/client/heroin.lua b/client/heroin.lua index 63ca514..87407ee 100644 --- a/client/heroin.lua +++ b/client/heroin.lua @@ -1,52 +1,29 @@ local QBCore = exports['qb-core']:GetCoreObject() -local CocaPlant = {} local PoppyPlants = {} local herointable = false -local function loadParticle(dict) - if not HasNamedPtfxAssetLoaded(dict) then - RequestNamedPtfxAsset(dict) - end - while not HasNamedPtfxAssetLoaded(dict) do - Wait(0) - end - SetPtfxAssetNextCall(dict) + +local function pickher(loc) + if not progressbar(Lang.Heroin.pick, 4000, 'uncuff') then return end + TriggerServerEvent("heroin:pickupCane", loc) end + CreateThread(function() local Ped = "g_m_y_famdnf_01" lib.requestModel("g_m_y_famdnf_01", Config.RequestModelTime) local labkitlocation = Config.buyheroinlabkit local heroinkitdealer = CreatePed(0, Ped, labkitlocation.x, labkitlocation.y, labkitlocation.z-1, labkitlocation.w, false, false) Freeze(heroinkitdealer, true, labkitlocation.w) - local options = { - { label = "Buy Heroin Lab Kit", icon = "fas fa-eye", event = "md-drugs:client:buyheroinlabkit", distance = 2.0}, - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(heroinkitdealer, options) - else - exports['qb-target']:AddTargetEntity(heroinkitdealer, { options = options, distance = 2.0}) - end + AddSingleModel(heroinkitdealer, { label = "Buy Heroin Lab Kit", icon = "fas fa-eye", event = "md-drugs:client:buyheroinlabkit", distance = 2.0}, nil ) end) ---- plant spawns dont edit RegisterNetEvent('heroin:respawnCane', function(loc) local v = GlobalState.PoppyPlants[loc] local hash = GetHashKey(v.model) - if not PoppyPlants[loc] then PoppyPlants[loc] = CreateObject(hash, v.location, false, true, true) Freeze(PoppyPlants[loc], true, v.heading) - exports['qb-target']:AddTargetEntity(PoppyPlants[loc], { - options = { { - icon = "fas fa-hand", - label = "pick Poppies", - action = function() - if not progressbar(Lang.Heroin.pick, 4000, 'uncuff') then return end - TriggerServerEvent("heroin:pickupCane", loc) - end - } - }, - distance = 2.5 - }) + AddSingleModel(PoppyPlants[loc], {icon = "fas fa-hand", label = "pick Poppies", action = function() pickher(loc) end}, loc ) end end) @@ -66,18 +43,7 @@ RegisterNetEvent("heroin:init", function() if not v.taken then PoppyPlants[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true) Freeze(PoppyPlants[k], true, v.heading) - exports['qb-target']:AddTargetEntity(PoppyPlants[k], { - options = { { - icon = "fas fa-hand", - label = "Pick Poppies", - action = function() - if not progressbar(Lang.Heroin.pick, 4000, 'uncuff') then return end - TriggerServerEvent("heroin:pickupCane", k) - end - } - }, - distance = 2.5 - }) + AddSingleModel(PoppyPlants[k], {icon = "fas fa-hand", label = "pick Poppies", action = function() pickher(k) end}, k ) end end end) @@ -126,37 +92,37 @@ RegisterNetEvent("md-drugs:client:buyheroinlabkit", function() TriggerServerEvent("md-drugs:server:getheroinlabkit") end) -RegisterNetEvent("md-drugs:client:setheroinlabkit") -AddEventHandler("md-drugs:client:setheroinlabkit", function() + +RegisterNetEvent("md-drugs:client:setheroinlabkit", function() if herointable then Notify(Lang.Heroin.tableout, 'error') else -local PedCoords = GetEntityCoords(PlayerPedId()) - if not progressbar(Lang.Heroin.table, 4000, 'uncuff') then TriggerServerEvent('md-drugs:server:getheroinlabkitback') return end herointable = true - local heroinlabkit = CreateObject("v_ret_ml_tablea", PedCoords.x+1, PedCoords.y+1, PedCoords.z-1, true, false) + 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 + local heroinlabkit = CreateObject("v_ret_ml_tablea", location.x, location.y, location.z, true, false) + SetEntityHeading(heroinlabkit, head) PlaceObjectOnGroundProperly(heroinlabkit) local options = { { event = "md-drugs:client:heatliquidheroin", icon = "fas fa-box-circle-check", label = "Cook Heroin", data = heroinlabkit}, { event = "md-drugs:client:getheroinkitback", icon = "fas fa-box-circle-check", label = "Pick Up", data = heroinlabkit, canInteract = function() if herointable then return true end end}, } - if Config.oxtarget then - exports.ox_target:addLocalEntity(heroinlabkit, options) - else - exports['qb-target']:AddTargetEntity(heroinlabkit, {options = options}) - end + AddMultiModel(heroinlabkit, options, heroinlabkit) end end) RegisterNetEvent("md-drugs:client:heatliquidheroin", function(data) -local PedCoords = GetEntityCoords(PlayerPedId()) + local loc = GetEntityCoords(data.data) + local head = GetEntityHeading(data.data) if not ItemCheck('emptyvial') then return end if not minigame(2, 8) then TriggerServerEvent("md-drugs:server:failheatingheroin") DeleteObject(data.data) - Wait(100) - local dirtylabkitheroin = CreateObject("v_ret_ml_tablea", PedCoords.x+1, PedCoords.y+1, PedCoords.z-1, true, false) + local dirtylabkitheroin = CreateObject("v_ret_ml_tablea", loc.x, loc.y, loc.z-1, true, false) + SetEntityHeading(dirtylabkitheroin, head) + PlaceObjectOnGroundProperly(dirtylabkitheroin) loadParticle("core") heroinkit = StartParticleFxLoopedOnEntity("exp_air_molotov", dirtylabkitheroin, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false) SetParticleFxLoopedAlpha(heroinkit, 3.0) @@ -164,11 +130,7 @@ local PedCoords = GetEntityCoords(PlayerPedId()) local options = { { event = "md-drugs:client:cleanheroinlabkit", icon = "fas fa-box-circle-check", label = "Clean It", data = dirtylabkitheroin} } - if Config.oxtarget then - exports.ox_target:addLocalEntity(dirtylabkitheroin,options ) - else - exports['qb-target']:AddTargetEntity(dirtylabkitheroin, {options = options}) - end + AddMultiModel(dirtylabkitheroin, options, nil ) return end if not progressbar(Lang.Heroin.success, 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:heatliquidheroin") @@ -181,11 +143,18 @@ RegisterNetEvent("md-drugs:client:cleanheroinlabkit", function(data) TriggerServerEvent("md-drugs:server:removecleaningkitheroin", data.data) end) -RegisterNetEvent("md-drugs:client:deletedirtyheroin", function(data) -DeleteObject(data) -herointable = false -Wait(1000) -TriggerEvent("md-drugs:client:setheroinlabkit") +RegisterNetEvent("md-drugs:client:deletedirtyheroin", function(data) +local location = GetEntityCoords(data) +local head = GetEntityHeading(data) + DeleteObject(data) + local heroinlabkit = CreateObject("v_ret_ml_tablea", location.x, location.y, location.z-1, true, false) + SetEntityHeading(heroinlabkit, head) + PlaceObjectOnGroundProperly(heroinlabkit) + local options = { + { event = "md-drugs:client:heatliquidheroin", icon = "fas fa-box-circle-check", label = "Cook Heroin", data = heroinlabkit}, + { event = "md-drugs:client:getheroinkitback", icon = "fas fa-box-circle-check", label = "Pick Up", data = heroinlabkit, canInteract = function() if herointable then return true end end}, + } + AddMultiModel(heroinlabkit, options, heroinlabkit) end) diff --git a/client/lean.lua b/client/lean.lua index ffdeee3..202bcfd 100644 --- a/client/lean.lua +++ b/client/lean.lua @@ -5,14 +5,7 @@ CreateThread(function() lib.requestModel(current, Config.RequestModelTime) local SyrupLocation = CreatePed(0, current,Config.SyrupVendor.x,Config.SyrupVendor.y,Config.SyrupVendor.z-1, Config.SyrupVendor.w, false, false) Freeze(SyrupLocation, true, Config.SyrupVendor.w) - local options = { - { type = "client", label = "Get Task", icon = "fas fa-eye", event = "md-drugs:client:getsyruplocationtobuy", distance = 2.0}, - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(SyrupLocation, options) - else - exports['qb-target']:AddTargetEntity(SyrupLocation, { options = options, distance = 2.0}) - end + AddSingleModel(SyrupLocation, { type = "client", label = "Get Task", icon = "fas fa-eye", event = "md-drugs:client:getsyruplocationtobuy", distance = 2.0}, nil ) end) @@ -20,3 +13,43 @@ RegisterNetEvent("md-drugs:client:getsyruplocationtobuy", function() Notify(Lang.Lean.marked, "success") SpawnCarPedChase() end) + +RegisterNetEvent('md-drugs:client:leancraft', function() +local store = {} +local label = {} +local items = lib.callback.await('md-drugs:server:GetRecipe', false,'lean', 'cups') +for k, v in pairs (items) do + label = {} + local item = '' + for m, d in pairs (items[k].take) do + table.insert(label, GetLabel(m) .. ' X ' .. d) + end + for m,d in pairs (items[k].give) do + item = m + end + store[#store + 1] = { + icon = GetImage(item), + description = table.concat(label, ", "), + title = GetLabel(item), + event = 'md-drugs:client:stirlean', + args = { + item = item, + recipe = 'weed', + num = k, + label = 'Cooking Up ' .. GetLabel(item), + table = 'edibles' + + } + } + lib.registerContext({id = 'leanCraft',title = "Make Lean", options = store}) +end +lib.showContext('leanCraft') +end) +local busy = false +RegisterNetEvent('md-drugs:client:stirlean', function(data) +if busy then return end + busy = true +if not progressbar(data.label, 4000, 'uncuff') then busy = false return end +TriggerServerEvent('md-drugs:server:finishcup', data) +busy = false +end) \ No newline at end of file diff --git a/client/lsd.lua b/client/lsd.lua index 34ee9a5..ab63013 100644 --- a/client/lsd.lua +++ b/client/lsd.lua @@ -17,14 +17,7 @@ local Ped = "g_m_y_famdnf_01" lib.requestModel(Ped, Config.RequestModelTime) local tabdealer = CreatePed(0, Ped,Config.buylsdlabkit.x,Config.buylsdlabkit.y,Config.buylsdlabkit.z-1, Config.buylsdlabkit.w, false, false) Freeze(tabdealer, true, Config.buylsdlabkit.w) - local options = { - { type = "client", label = "Buy LSD Lab Kit", icon = "fas fa-eye", event = "md-drugs:client:buylabkit", distance = 2.0} - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(tabdealer, options) - else - exports['qb-target']:AddTargetEntity(tabdealer, {options = options, distance = 2.0}) - end + AddSingleModel(tabdealer,{ type = "client", label = "Buy LSD Lab Kit", icon = "fas fa-eye", event = "md-drugs:client:buylabkit", distance = 2.0}, tabdealer ) end) @@ -41,29 +34,25 @@ RegisterNetEvent("md-drugs:client:getdiethylamide", function(data) TriggerServerEvent('md-drugs:server:getdiethylamide', data.data) end) -RegisterNetEvent("md-drugs:client:setlsdlabkit") -AddEventHandler("md-drugs:client:setlsdlabkit", function() +RegisterNetEvent("md-drugs:client:setlsdlabkit", function() if tableout then Notify(Lang.lsd.tableout, 'error') TriggerServerEvent('md-drugs:server:getlabkitback') else tableout = true - local PedCoords = GetEntityCoords(PlayerPedId()) + 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 - local labkit = CreateObject("v_ret_ml_tablea", PedCoords.x+1, PedCoords.y+1, PedCoords.z-1, true, false) + local labkit = CreateObject("v_ret_ml_tablea", loc.x, loc.y, loc.z-1, true, false) + SetEntityHeading(labkit, head) PlaceObjectOnGroundProperly(labkit) - local options = { - { event = "md-drugs:client:heatliquid", icon = "fas fa-box-circle-check", label = "Heat Liquid" , data = labkit, }, - { event = "md-drugs:client:refinequalityacid", icon = "fas fa-box-circle-check", label = "Refine", data = labkit, }, - { event = "md-drugs:client:maketabpaper", icon = "fas fa-box-circle-check", label = "Dab Sheets", data = labkit, }, - { event = "md-drugs:client:getlabkitback", icon = "fas fa-box-circle-check", label = "Pick Up", data = labkit, canInteract = function() if tableout then return true end end}, + { event = "md-drugs:client:heatliquid", icon = "fas fa-box-circle-check", label = "Heat Liquid" , data = labkit, }, + { event = "md-drugs:client:refinequalityacid", icon = "fas fa-box-circle-check", label = "Refine", data = labkit, }, + { event = "md-drugs:client:maketabpaper", icon = "fas fa-box-circle-check", label = "Dab Sheets", data = labkit, }, + { event = "md-drugs:client:getlabkitback", icon = "fas fa-box-circle-check", label = "Pick Up", data = labkit, canInteract = function() if tableout then return true end end}, } - if Config.oxtarget then - exports.ox_target:addLocalEntity(labkit, options) - else - exports['qb-target']:AddTargetEntity(labkit, {options = options}) - end + AddMultiModel(labkit, options, labkit) end end) @@ -75,26 +64,23 @@ RegisterNetEvent("md-drugs:client:getlabkitback", function(data) end) RegisterNetEvent("md-drugs:client:heatliquid", function(data) - local PedCoords = GetEntityCoords(PlayerPedId()) + local PedCoords = GetEntityCoords(data.data) dict = "scr_ie_svm_technical2" if not ItemCheck('lysergic_acid') then return end if not ItemCheck('diethylamide') then return end if not minigame(2, 8) then TriggerServerEvent("md-drugs:server:failheating") DeleteObject(data.data) - local dirtylabkit = CreateObject("v_ret_ml_tablea", PedCoords.x+1, PedCoords.y+1, PedCoords.z-1, true, false) + local dirtylabkit = CreateObject("v_ret_ml_tablea", PedCoords.x, PedCoords.y, PedCoords.z-1, true, false) loadParticle(dict) exitPtfx = StartParticleFxLoopedOnEntity("scr_dst_cocaine", dirtylabkit, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false) PlaceObjectOnGroundProperly(dirtylabkit) SetParticleFxLoopedAlpha(exitPtfx, 3.0) - local options = { - { event = "md-drugs:client:cleanlabkit", icon = "fas fa-box-circle-check", label = "Clean It", data = dirtylabkit }, + Wait(100) + local options = { + { event = "md-drugs:client:cleanlabkit", icon = "fas fa-box-circle-check", label = "Clean It", data = dirtylabkit} } - if Config.oxtarget then - exports.ox_target:addLocalEntity(dirtylabkit, options) - else - exports['qb-target']:AddTargetEntity(dirtylabkit, { options = options}) - end + AddMultiModel(dirtylabkit, options, nil ) return end if not progressbar(Lang.lsd.heat, 7000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:heatliquid") @@ -103,17 +89,22 @@ 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 - tableout = false - TriggerServerEvent("md-drugs:server:removecleaningkit", data.data) + local check = lib.callback.await('md-drugs:server:removecleaningkit') + if check then + local coord = GetEntityCoords(data.data) + DeleteObject(data.data) + local labkit = CreateObject("v_ret_ml_tablea", coord.x, coord.y, coord.z-1, true, false) + PlaceObjectOnGroundProperly(labkit) + local options = { + { event = "md-drugs:client:heatliquid", icon = "fas fa-box-circle-check", label = "Heat Liquid" , data = labkit, }, + { event = "md-drugs:client:refinequalityacid", icon = "fas fa-box-circle-check", label = "Refine", data = labkit, }, + { event = "md-drugs:client:maketabpaper", icon = "fas fa-box-circle-check", label = "Dab Sheets", data = labkit, }, + { event = "md-drugs:client:getlabkitback", icon = "fas fa-box-circle-check", label = "Pick Up", data = labkit, canInteract = function() if tableout then return true end end}, + } + AddMultiModel(labkit, options, labkit) + end end) - -RegisterNetEvent("md-drugs:client:resetlsdkit", function(data) -DeleteObject(data) -TriggerEvent("md-drugs:client:setlsdlabkit") -end) - - RegisterNetEvent("md-drugs:client:refinequalityacid", function() if not ItemCheck('lsd_one_vial') then return end if not minigame(2, 8) then TriggerServerEvent("md-drugs:server:failrefinequality") return end diff --git a/client/mescaline.lua b/client/mescaline.lua index 4125a75..b02a55b 100644 --- a/client/mescaline.lua +++ b/client/mescaline.lua @@ -8,19 +8,17 @@ function LoadModel(hash) Wait(3000) end end - +local function pick(loc) + if not progressbar(Lang.mescaline.pick, 4000, 'uncuff') then return end + TriggerServerEvent("Mescaline:pickupCane", loc) +end RegisterNetEvent('Mescaline:respawnCane', function(loc) local v = GlobalState.Mescaline[loc] local hash = GetHashKey(v.model) if not Mescaline[loc] then Mescaline[loc] = CreateObject(hash, v.location, false, true, true) Freeze(Mescaline[loc], true, v.heading) - exports['qb-target']:AddTargetEntity(Mescaline[loc], { - options = { - {icon = "fas fa-hand",label = "pick Cactus",action = function() if not progressbar(Lang.mescaline.pick, 4000, 'uncuff') then return end TriggerServerEvent("Mescaline:pickupCane", loc)end} - }, - distance = 2.5 - }) + AddSingleModel(Mescaline[loc], {icon = "fas fa-hand",label = "pick Cactus",action = function() pick(loc) end}, loc ) end end) @@ -40,11 +38,7 @@ RegisterNetEvent("Mescaline:init", function() if not v.taken then Mescaline[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true) Freeze(Mescaline[k], true, v.heading) - exports['qb-target']:AddTargetEntity(Mescaline[k], { - options = { { icon = "fas fa-hand", label = "Pick Mescaline", action = function() if not progressbar(Lang.mescaline.pick, 4000, 'uncuff') then return end TriggerServerEvent("Mescaline:pickupCane", k) end} - }, - distance = 2.5 - }) + AddSingleModel(Mescaline[k], {icon = "fas fa-hand",label = "pick Cactus",action = function() pick(k) end}, k) end end end) diff --git a/client/meth.lua b/client/meth.lua index 1a8ca64..d65da0e 100644 --- a/client/meth.lua +++ b/client/meth.lua @@ -5,6 +5,9 @@ local heated = nil local active = nil local function startcook() + if not ItemCheck('empty_weed_bag') then return end + if not ItemCheck('acetone') then return end + if not ItemCheck('ephedrine') then return end if amonia == nil then active = true TriggerServerEvent("md-drugs:server:startcook") @@ -35,49 +38,10 @@ if tray then tray = false DeleteObject(trays) local bucket = CreateObject(`bkr_prop_meth_bigbag_03a`, vector3(1012.85, -3194.29, -39.2), true, true, true) - SetEntityHeading(bucket, 90.0) + Freeze(bucket, true, 90.0) SmashMeth() - - local options = { - { - name = 'bucket', - icon = 'fa-solid fa-car', - label = 'Bag Meth', - action = function() - DeleteObject(bucket) - amonia = nil - heated = nil - tray = nil - active = nil - BagMeth() - TriggerServerEvent('md-drugs:server:getmeth') - - end, - - } - } - local optionsox = { - { - name = 'bucket', - icon = 'fa-solid fa-car', - label = 'Bag Meth', - onSelect = function() - DeleteObject(bucket) - amonia = nil - heated = nil - tray = nil - active = nil - BagMeth() - TriggerServerEvent('md-drugs:server:getmeth') - end, - - } - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(bucket, optionsox) - else - exports['qb-target']:AddTargetEntity(bucket, {options = options, distance = 2.0}) - end + Wait(100) + AddSingleModel(bucket, {name = 'bucket',icon = 'fa-solid fa-car',label = 'Bag Meth',action = function() DeleteObject(bucket)amonia = nil heated = nil tray = nil active = nil BagMeth() TriggerServerEvent('md-drugs:server:getmeth')end,}, bucket) end end @@ -109,109 +73,58 @@ CreateThread(function() end) CreateThread(function() - exports['qb-target']:AddBoxZone("methteleout", Config.MethTeleIn, 1.5, 1.75, { name = "methteleout", heading = 11.0, debugPoly = false, minZ = Config.MethTeleIn.z - 2, maxZ = Config.MethTeleIn.z + 2,}, { - options = { - {name = 'teleout', icon = "fas fa-sign-in-alt", label = "Enter Building", action = function() SetEntityCoords(PlayerPedId(), Config.MethTeleOut) end}, - }, - distance = 2.5 - }) - exports['qb-target']:AddBoxZone("methtelein", Config.MethTeleOut, 1.5, 1.75, {name = "methtelein",heading = 11.0,debugPoly = false,minZ = Config.MethTeleOut.z - 2,maxZ = Config.MethTeleOut.z + 2,}, { - options = { - { name = 'teleout', icon = "fas fa-sign-in-alt", label = "Exit Building", action = function() SetEntityCoords(PlayerPedId(), Config.MethTeleIn) end }, - }, - distance = 2.5 - }) - exports['qb-target']:AddBoxZone("maze", vector3(-95.55, -806.73, 44.04), 1.5, 1.75, { name = "maze", heading = 11.0, debugPoly = false, minZ = 44 - 2, maxZ = 44 + 2, }, { - options = { - { name = 'die', icon = "fas fa-sign-in-alt", label = "dont click this", action = function() SetEntityCoords(PlayerPedId(), vector3(-75.36, -837.24, 318.93)) end}, - }, - distance = 2.5 - }) + + AddBoxZoneSingle("methTeleOut",Config.MethTeleIn, {name = 'teleout', icon = "fas fa-sign-in-alt", label = "Enter Building", action = function() SetEntityCoords(PlayerPedId(), Config.MethTeleOut) end} ) + AddBoxZoneSingle("methtelein",Config.MethTeleOut, {name = 'teleout', icon = "fas fa-sign-in-alt", label = "Enter Building", action = function() SetEntityCoords(PlayerPedId(), Config.MethTeleOut) end} ) local itemreqcook = { "ephedrine", "acetone" } - exports['qb-target']:AddBoxZone("ingridientsmeth", vector3(1005.7, -3201.28, -39.55), 1.5, 1.75,{ name = "ingridientsmeth", heading = 11.0, debugPoly = false, minZ = -39 - 2, maxZ = -39 + 2,}, { - options = { - { name = 'methcook', icon = "fas fa-sign-in-alt", label = "Cook Meth", item = itemreqcook, action = function() startcook() end, - canInteract = function() - if amonia == nil and active == nil then - return true - end - end, - }, - { name = 'grabtray', icon = "fas fa-sign-in-alt", label = "Grab Tray", distance = 5, action = function() trayscarry() end, - canInteract = function() - if heated and amonia and tray == nil then return true end - end, - }, + local options = { + { name = 'methcook', icon = "fas fa-sign-in-alt", label = "Cook Meth", action = function() startcook() end, + canInteract = function() + if amonia == nil and active == nil then + return true + end + end, }, - distance = 2.5 - }) - exports['qb-target']:AddBoxZone("boxmeth", vector3(1012.15, -3194.04, -39.20), 1.5, 1.75,{ name = "boxmeth", heading = 3.0, debugPoly = false, minZ = -39 - 2, maxZ = -39 + 2,}, { - options = { - {name = 'boxmeth',icon = "fas fa-sign-in-alt",label = "Box Up Meth",distance = 5,action = function() smash()end, - canInteract = function() - if tray then return true end - end, - }, + { name = 'grabtray', icon = "fas fa-sign-in-alt", label = "Grab Tray", action = function() trayscarry() end, + canInteract = function() + if heated and amonia and tray == nil then return true end + end, }, - }) - exports['qb-target']:AddBoxZone("adjustdials", vector3(1007.89, -3201.17, -38.99), 1.5, 1.75,{ name = "adjustdials", heading = 11.0, debugPoly = false, minZ = -39 - 2, maxZ = -39 + 2,}, { - options = { - { name = 'adjustdials', icon = "fas fa-sign-in-alt", label = "Adjust Dials", distance = 5, action = function() dials() end, - canInteract = function() - if amonia and heated == nil then return true end end - }, - }, - }) + } + AddBoxZoneSingle("cookmeth",vector3(1005.7, -3201.28, -39.55), options ) + AddBoxZoneSingle('boxmeth', vector3(1012.15, -3194.04, -39.20), {name = 'boxmeth',icon = "fas fa-sign-in-alt",label = "Box Up Meth",action = function() smash()end, + canInteract = function() + if tray then return true end + end}) + AddBoxZoneSingle('adjustdials',vector3(1007.89, -3201.17, -38.99),{ name = 'adjustdials', icon = "fas fa-sign-in-alt", label = "Adjust Dials", distance = 5, action = function() dials() end, + canInteract = function() + if amonia and heated == nil then return true end end + }) if Config.MethHeist == false then - for k, v in pairs (Config.MethEph) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - exports['qb-target']:AddBoxZone("methep"..k, v.loc, v.l, v.w, { name = "methep"..k, heading = v.rot, minZ = v.loc.z - 1.0, maxZ = v.loc.z + 2.0,}, { - options = { - {icon = "fas fa-sign-in-alt", label = "Steal Ephedrine", event = 'md-drugs:client:stealeph', data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - }, - }, - distance = 2.5 - }) - end - for k, v in pairs (Config.Methace) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - exports['qb-target']:AddBoxZone("methace"..k, v.loc, v.l, v.w, { name = "methace"..k, heading = v.rot, minZ = v.loc.z - 1.0, maxZ = v.loc.z + 2.0,}, { - options = { - {icon = "fas fa-sign-in-alt", label = "Steal Acetone", event = 'md-drugs:client:stealace', data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - }, - }, - distance = 2.5 - }) - end + AddBoxZoneMulti('methep', Config.MethEph, {icon = "fas fa-sign-in-alt", label = "Steal Ephedrine", event = 'md-drugs:client:stealeph'}) + AddBoxZoneMulti('methace', Config.Methace, {icon = "fas fa-sign-in-alt", label = "Steal Acetone", event = 'md-drugs:client:stealace'}) end end) CreateThread(function() -if Config.MethHeist == false then -else +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) - exports['qb-target']:AddTargetEntity(methdealer, { - options = { - { - label = "Get Mission", - icon = "fas fa-eye", - action = function() - Notify(Lang.meth.mission, "success") - SpawnMethCarPedChase() - end, - }, - } - }) + Wait(100) + AddSingleModel(methdealer,{ + label = "Get 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 715ebbb..69f132c 100644 --- a/client/oxyruns.lua +++ b/client/oxyruns.lua @@ -2,73 +2,56 @@ local QBCore = exports['qb-core']:GetCoreObject() local deliveryBlip = nil local carryPackage = nil - -RegisterNetEvent("md-drugs:client:getoxytruck", function() -if TriggerServerEvent('md-drugs:server:payfortruck') then -end -end) - - -RegisterNetEvent("md-drugs:Client:getoxylocation", function() - local coords = Config.truckspawn - local ModelHash = "burrito3" -- Use Compile-time hashes to get the hash of this model - lib.requestModel(ModelHash, Config.RequestModelTime) - local oxycar = CreateVehicle(ModelHash,Config.truckspawn.x, Config.truckspawn.y,Config.truckspawn.z, Config.truckspawn.h, true, false) - SetEntityHeading(oxycar, coords.w) +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.h, true, false) exports[Config.Fuel]:SetFuel(oxycar, 100.0) TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(oxycar)) Notify(Lang.oxy.truck, 'success') TriggerEvent("md-drugs:client:getoxylocationroute") SetVehicleEngineOn(oxycar, true, true) - local options = { - { event = "md-drugs:client:getfromtrunk", icon = "fas fa-box-circle-check", label = "Get Package"}, - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(oxycar, options) - else - exports['qb-target']:AddTargetEntity(oxycar, {options = options, distance = 2.0}) - end - + AddSingleModel(oxycar, { event = "md-drugs:client:getfromtrunk", icon = "fas fa-box-circle-check", label = "Get Package"}, nil ) end) RegisterNetEvent("md-drugs:client:getoxylocationroute", function() - Wait(100) - local unlucky = math.random(1,100) local CurrentLocation = Config.oxylocations[math.random(#Config.oxylocations)] - local unluck = math.random(1,100) - if deliveryBlip ~= nil then - RemoveBlip(deliveryBlip) - end if CurrentLocation ~= nil then - deliveryBlip = AddBlipForCoord(CurrentLocation) + local deliveryBlip = AddBlipForCoord(CurrentLocation) SetBlipSprite(deliveryBlip, 1) SetBlipDisplay(deliveryBlip, 2) SetBlipScale(deliveryBlip, 1.0) SetBlipAsShortRange(deliveryBlip, false) SetBlipColour(deliveryBlip, 27) BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName("drug Meet") + AddTextComponentSubstringPlayerName(text) EndTextCommandSetBlipName(deliveryBlip) SetBlipRoute(deliveryBlip, true) - local current = "g_m_y_famdnf_01" - lib.requestModel(current, Config.RequestModelTime) + local current = "g_m_y_famdnf_01" + lib.requestModel(current, Config.RequestModelTime) local oxybuyer = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false) - Freeze(oxybuyer, true, CurrentLocation.w) - repeat - Wait(1000) - until #(GetEntityCoords(PlayerPedId()) - vector3(CurrentLocation.x,CurrentLocation.y,CurrentLocation.z)) < 5.0 + Freeze(oxybuyer, true, CurrentLocation.w) + repeat + Wait(1000) + until #(GetEntityCoords(PlayerPedId()) - vector3(CurrentLocation.x,CurrentLocation.y,CurrentLocation.z)) < 5.0 RemoveBlip(deliveryBlip) - PoliceCall(Config.PoliceAlertOxy) - local options = { - { type = "client", label = "Talk To Buyer", icon = "fas fa-eye", event = "md-drugs:client:giveoxybox", ped = oxybuyer}, - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(oxybuyer, options) - else - exports['qb-target']:AddTargetEntity(oxybuyer, {options = options, distance = 2.0}) - end + PoliceCall(Config.PoliceAlertOxy) + AddSingleModel(oxybuyer, { type = "client", label = "Talk To Buyer", icon = "fas fa-eye", + action = function() + if carryPackage then + if not progressbar(Lang.oxy.hand, 4000, 'uncuff') then return end + TriggerServerEvent("md-drugs:server:giveoxybox") + DeleteEntity(oxybuyer) + DetachEntity(carryPackage, true, true) + DeleteObject(carryPackage) + carryPackage = nil + else + Notify(Lang.oxy.empty, "error") + end + end}, oxybuyer) end end) @@ -95,6 +78,7 @@ end) RegisterNetEvent("md-drugs:client:giveoxybox", function(data) + if carryPackage then if not progressbar(Lang.oxy.hand, 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:giveoxybox") diff --git a/client/shrooms.lua b/client/shrooms.lua index 5be41a6..5507ebc 100644 --- a/client/shrooms.lua +++ b/client/shrooms.lua @@ -9,18 +9,17 @@ function LoadModel(hash) Wait(3000) end end - +local function pick(loc) + if not progressbar(Lang.Shrooms.pick, 4000, 'uncuff') then return end + TriggerServerEvent("shrooms:pickupCane", loc) +end RegisterNetEvent('shrooms:respawnCane', function(loc) local v = GlobalState.shrooms[loc] local hash = GetHashKey(v.model) if not shrooms[loc] then shrooms[loc] = CreateObject(hash, v.location, false, true, true) Freeze(shrooms[loc], true, v.heading) - exports['qb-target']:AddTargetEntity(shrooms[loc], { - options = { { icon = "fas fa-hand", label = "pick shrooms", action = function() if not progressbar(Lang.Shrooms.pick, 4000, 'uncuff') then return end TriggerServerEvent("shrooms:pickupCane", loc) end } - }, - distance = 2.5 - }) + AddSingleModel(shrooms[loc],{ icon = "fas fa-hand", label = "pick shrooms", action = function() pick(loc) end }, loc ) end end) AddEventHandler('onResourceStart', function(resource) @@ -61,11 +60,7 @@ end) if not v.taken then shrooms[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true) Freeze(shrooms[k], true, v.heading) - exports['qb-target']:AddTargetEntity(shrooms[k], { - options = { { icon = "fas fa-hand", label = "Pick shrooms", action = function() if not progressbar(Lang.Shrooms.pick, 4000, 'uncuff') then return end TriggerServerEvent("shrooms:pickupCane", k) end } - }, - distance = 2.5 - }) + AddSingleModel(shrooms[k],{ icon = "fas fa-hand", label = "pick shrooms", action = function() pick(k) end }, k ) end end end) diff --git a/client/target.lua b/client/target.lua index 3648042..c25572c 100644 --- a/client/target.lua +++ b/client/target.lua @@ -1,298 +1,23 @@ local QBCore = exports['qb-core']:GetCoreObject() CreateThread(function() - -if Config.oxtarget then - coketelein = exports.ox_target:addBoxZone({ coords = Config.CokeTeleIn, size = vec(1,1,3), rotation = 0, debug = false, - options = { - {name = 'teleout',icon = "fas fa-sign-in-alt",label = "Enter Building",distance = 5, - onSelect = function() - DoScreenFadeOut(500) - Wait(1000) - SetEntityCoords(PlayerPedId(),Config.CokeTeleOut.x, Config.CokeTeleOut.y, Config.CokeTeleOut.z) - Wait(1000) - DoScreenFadeIn(500) - end - }, - }, - }) - coketeleout = exports.ox_target:addBoxZone({ coords = Config.CokeTeleOut, size = vec(1,1,3), rotation = 0, debug = false, - options = { - {name = 'teleout',icon = "fas fa-sign-in-alt",label = "Exit Building",distance = 5, - onSelect = function() - DoScreenFadeOut(500) - Wait(500) - SetEntityCoords(PlayerPedId(),Config.CokeTeleIn) - Wait(500) - DoScreenFadeIn(500) - end, - - }, - }, - }) -else - exports['qb-target']:AddBoxZone("coketelein",Config.CokeTeleIn,1.5, 1.75, { name = "coketelein",heading = 156.0,debugPoly = false,minZ = Config.CokeTeleIn.z-2,maxZ = Config.CokeTeleIn.z+2,}, { - options = { - { - name = 'teleout', - icon = "fas fa-sign-in-alt", - label = "Enter Building", - action = function() - DoScreenFadeOut(500) - Wait(500) - SetEntityCoords(PlayerPedId(),Config.CokeTeleOut) - Wait(500) - DoScreenFadeIn(500) - end, - - }, - }, - }) - exports['qb-target']:AddBoxZone("CokeTeleOut",Config.CokeTeleOut,1.5, 1.75, {name = "CokeTeleOut",heading = 156.0,debugPoly = false,minZ = Config.CokeTeleOut.z-2,maxZ = Config.CokeTeleOut.z+2,}, { - options = { - { - name = 'teleout', - icon = "fas fa-sign-in-alt", - label = "Exit Building", - action = function() - DoScreenFadeOut(500) - Wait(500) - SetEntityCoords(PlayerPedId(),Config.CokeTeleIn) - Wait(500) - DoScreenFadeIn(500) - end, - - }, - }, - }) -end - -- cocaine ( Bagging and Cutting is in Cocaine.lua due to globals used :)) - for k, v in pairs (Config.MakePowder) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:makepowder", icon = "fas fa-sign-in-alt", label = "chop it up", data = k, distance = 2.0, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - }, - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("makepowder"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="makepowder"..k, heading = 156.0,minZ = v.loc.z-1, maxZ = v.loc.z+1, }, {options = options, distance = 1.5}) - end - end - ------------- lsd - for k, v in pairs (Config.lysergicacid) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:getlysergic", icon = "fas fa-sign-in-alt", label = "stealing", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false, rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("getlysergic"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="getlysergic"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.diethylamide) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:getdiethylamide", icon = "fas fa-sign-in-alt", label = "stealing", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("getdiethylamide"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="getdiethylamide"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.gettabs) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:buytabs", icon = "fas fa-sign-in-alt", label = "Buy Tabs", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("buytabs"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="buytabs"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - ------ heroin - for k, v in pairs (Config.dryplant) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:dryplant", icon = "fas fa-sign-in-alt", label = "Dry Poppies", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("dryplant"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="dryplant"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.cutheroinone) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:cutheroin", icon = "fas fa-sign-in-alt", label = "Cut Heroin", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("cutheroin"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="cutheroin"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.fillneedle) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:fillneedle", icon = "fas fa-sign-in-alt", label = "Fill Needles", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("fillneedle"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="fillneedle"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - ------- crack - for k, v in pairs (Config.makecrack) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:makecrackone", icon = "fas fa-sign-in-alt", label = "Cook Crack", data = k, distance = 2.0, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("makecrackone"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="makecrackone"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.bagcrack) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:bagcrack", icon = "fas fa-sign-in-alt", label = "Bag Crack", data = k, distance = 2.0, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("bagcrack"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="bagcrack"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - ------- pharma - for k, v in pairs (Config.FillPrescription) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:fillprescription", icon = "fas fa-sign-in-alt", label = "Fill Prescription", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("fillprescription"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="fillprescription"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - -------- oxy runs - local options2 = { - { event = "md-drugs:client:getoxytruck", icon = "fas fa-sign-in-alt", label = "Pay For Truck",}, - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = Config.Payfortruck, size = vec3(1,1,1),debugPoly = false,rotation = 90.0, options = options2,}) - else - exports['qb-target']:AddBoxZone("payfortruck" ,Config.Payfortruck, 1.0, 1.0, {name ="payfortruck", heading = 156.0,minZ = Config.Payfortruck.z-2, maxZ = Config.Payfortruck.z+2, }, {options = options2, distance = 1.5}) - end - ------------ mescaline - local options3 = { - { type = "client", event = "md-drugs:client:drymescaline", icon = "fas fa-sign-in-alt", label = "Dry Out"}, - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = Config.DryOut, size = vec3(1,1,1),debugPoly = false,rotation = 90.0, options = options3,}) - else - exports['qb-target']:AddBoxZone("DryOut" ,Config.DryOut, 1.0, 1.0, {name ="DryOut", heading = 156.0,minZ = Config.DryOut.z-2, maxZ = Config.DryOut.z+2, }, {options = options3, distance = 1.5}) - end - ------ XTC - for k, v in pairs (Config.isosafrole) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:stealisosafrole", icon = "fas fa-sign-in-alt", label = "Steal Isosafrole", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("stealisosafrole"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="stealisosafrole"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - for k, v in pairs (Config.mdp2p) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:stealmdp2p", icon = "fas fa-sign-in-alt", label = "Steal MDP2P", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("stealmdp2p"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="stealmdp2p"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - - for k, v in pairs (Config.rawxtcloc) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - { type = "client", event = "md-drugs:client:makingrawxtc", icon = "fas fa-sign-in-alt", label = "Make Raw XTC", data = k, - canInteract = function() - if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end - } - } - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("makingrawxtc"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="makingrawxtc"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - local options4 = { - { type = "client", event = "md-drugs:client:buypress", icon = 'fas fa-eye', label = 'Buy Press',}, - } - if Config.oxtarget then - exports.ox_target:addBoxZone({ coords = Config.buypress, size = vec3(2,2,2), debugPoly = false, rotation = 45, options = options4}) - else - exports['qb-target']:AddBoxZone("buypress" ,Config.buypress, 1.0, 1.0, {name ="buypress", heading = 156.0,minZ = Config.buypress.z-2, maxZ = Config.buypress.z+2, }, {options = options4, distance = 1.5}) - end - for k, v in pairs(Config.stamp) do - if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end - local options = { - {type = "client", event = "md-drugs:client:stampwhite", icon = 'fas fa-eye', label = 'Stamp Pills', data = k, canInteract = function() if QBCore.Functions.GetPlayerData().gang.name == v.gang or v.gang == 1 then return true end end }, - - } - - if Config.oxtarget then - exports.ox_target:addBoxZone({coords = v.loc, size = vec3(1,1,1),debugPoly = false,rotation = v.rot, options = options,}) - else - exports['qb-target']:AddBoxZone("stampxtc"..k ,vector3(v.loc.x, v.loc.y, v.loc.z), v.l, v.w, {name ="stampxtc"..k, heading = 156.0,minZ = v.loc.z-2, maxZ = v.loc.z+2, }, {options = options, distance = 1.5}) - end - end - + AddBoxZoneMulti('makepowder', Config.MakePowder, { type = "client", event = "md-drugs:client:makepowder", icon = "fas fa-sign-in-alt", label = "chop it up"}) -- coke + AddBoxZoneSingle('telecokein', Config.CokeTeleIn, {name = 'teleout',icon = "fas fa-sign-in-alt",label = "Enter Building",action = function() tele(Config.CokeTeleOut) end,}) -- coke + AddBoxZoneSingle('telecokeout', Config.CokeTeleOut, {name = 'teleout',icon = "fas fa-sign-in-alt",label = "Exit Building",action = function() tele(Config.CokeTeleIn) end,}) -- coke + AddBoxZoneMulti('steallysergic', Config.lysergicacid, { type = "client", event = "md-drugs:client:getlysergic", icon = "fas fa-sign-in-alt", label = "stealing Lysergic"}) -- lsd + AddBoxZoneMulti('stealdiethylamide', Config.diethylamide, {type = "client", event = "md-drugs:client:getdiethylamide", icon = "fas fa-sign-in-alt", label = "stealing Diethylamide"}) -- lsd + AddBoxZoneMulti('gettabs', Config.gettabs, {type = "client", event = "md-drugs:client:buytabs", icon = "fas fa-sign-in-alt", label = "Buy Tabs"}) -- lsd + AddBoxZoneMulti('dryheroin', Config.dryplant, {type = "client",event = "md-drugs:client:dryplant", icon = "fas fa-sign-in-alt", label = "Dry Poppies"}) -- heroin + AddBoxZoneMulti('cutheroin', Config.cutheroinone, {type = "client", event = "md-drugs:client:cutheroin", icon = "fas fa-sign-in-alt", label = "Cut Heroin"}) -- heroin + AddBoxZoneMulti('fillneedle', Config.fillneedle, {type = "client", event = "md-drugs:client:fillneedle", icon = "fas fa-sign-in-alt", label = "Fill Needles"}) -- heroin + AddBoxZoneMulti('makecrack', Config.makecrack, {type = "client", event = "md-drugs:client:makecrackone", icon = "fas fa-sign-in-alt", label = "Cook Crack"}) -- crack + AddBoxZoneMulti('bagcrack', Config.bagcrack, {type = "client", event = "md-drugs:client:bagcrack", icon = "fas fa-sign-in-alt", label = "Bag Crack"}) -- crack + AddBoxZoneMulti('fillprescription', Config.FillPrescription, {type = "client", event = "md-drugs:client:fillprescription", icon = "fas fa-sign-in-alt", label = "Fill Prescription"}) -- pharma + AddBoxZoneSingle('payfortruck', Config.Payfortruck, { event = "md-drugs:client:GetOxyCar", icon = "fas fa-sign-in-alt", label = "Pay For Truck"}) -- oxy runs + AddBoxZoneSingle('drymescaline', Config.DryOut, { type = "client", event = "md-drugs:client:drymescaline", icon = "fas fa-sign-in-alt", label = "Dry Out"}) -- mescaline + AddBoxZoneMulti('stealisosafrole', Config.isosafrole, {type = "client", event = "md-drugs:client:stealisosafrole", icon = "fas fa-sign-in-alt", label = "Steal Isosafrole"}) -- xtc + AddBoxZoneMulti('stealmdp2p', Config.mdp2p, {type = "client", event = "md-drugs:client:stealmdp2p", icon = "fas fa-sign-in-alt", label = "Steal MDP2P"}) -- xtc + AddBoxZoneMulti('rawxtcloc', Config.rawxtcloc, {type = "client", event = "md-drugs:client:makingrawxtc", icon = "fas fa-sign-in-alt", label = "Make Raw XTC"}) -- xtc + AddBoxZoneSingle('buypress', Config.buypress, { type = "client",event = "md-drugs:client:buypress", icon = 'fas fa-eye', label = 'Buy Press'}) -- xtc + AddBoxZoneMulti('stamp', Config.stamp, {type = "client", event = "md-drugs:client:stampwhite", icon = 'fas fa-eye', label = 'Stamp Pills'}) -- xtc end) diff --git a/client/travellingmerchant.lua b/client/travellingmerchant.lua index d2d45c1..bfed39c 100644 --- a/client/travellingmerchant.lua +++ b/client/travellingmerchant.lua @@ -3,26 +3,15 @@ local QBCore = exports['qb-core']:GetCoreObject() CreateThread(function() local current = "g_m_y_famdnf_01" lib.requestModel(current, Config.RequestModelTime) - local CurrentLocation = Config.Travellingmerchant[math.random(#Config.Travellingmerchant)] + local num = lib.callback.await('md-drugs:server:GetMerchant', false) + local CurrentLocation = Config.Travellingmerchant[num] local travellingmerchant = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false) Freeze(travellingmerchant, true, CurrentLocation.w) - if Config.oxtarget then - local options = { - { label = "Travelling Merchant", icon = "fas fa-eye", onSelect = function() lib.showContext('travellingmerchant') end}, - } - exports.ox_target:addLocalEntity(travellingmerchant, options) - else - exports['qb-target']:AddTargetEntity(travellingmerchant, { - options = { - { label = "Travelling Merchant", icon = "fas fa-eye", action = function() lib.showContext('travellingmerchant') end}, - } - }) - end + AddSingleModel(travellingmerchant, { label = "Travelling Merchant", icon = "fas fa-eye", action = function() lib.showContext('travellingmerchant') end}, nil) end) CreateThread(function() local ShopMenu = {} - for k, v in pairs (Config.Items.items) do ShopMenu[#ShopMenu + 1] = { icon = GetImage(v.name), @@ -37,13 +26,12 @@ CreateThread(function() num = k } } - lib.registerContext({id = 'travellingmerchant',title = "Travelling Merchant", options = ShopMenu}) end end) -RegisterNetEvent("md-drugs:client:travellingmerchantox", function(data) local dialog +RegisterNetEvent("md-drugs:client:travellingmerchantox", function(data) local price = data.cost local settext = "Amnt: "..data.amount.." | Cost: "..price or "Cost: "..price local max = data.amount diff --git a/client/weed.lua b/client/weed.lua index 9c20536..0998749 100644 --- a/client/weed.lua +++ b/client/weed.lua @@ -10,32 +10,31 @@ function LoadModel(hash) end end +local function hasJob() + if Config.Joblock then + if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then + return true else return false end + else + return true end + end + + RegisterNetEvent('weed:respawnCane', function(loc) local v = GlobalState.WeedPlant[loc] local hash = GetHashKey(v.model) if not HasModelLoaded(hash) then LoadModel(hash) end if not WeedPlant[loc] then WeedPlant[loc] = CreateObject(hash, v.location.x, v.location.y, v.location.z-3.5, false, true, true) - Freeze(WeedPlant[loc],true, v.heading) - exports['qb-target']:AddTargetEntity(WeedPlant[loc], { - options = { - { - icon = "fas fa-hand", - label = "Pick Weed", - action = function() - if not progressbar(Lang.Weed.pick, 4000, 'uncuff') then return end - TriggerServerEvent("weed:pickupCane", loc) - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - } - }, -distance = 2.5 - }) + Freeze(WeedPlant[loc],true, v.heading) + AddSingleModel(WeedPlant[loc], + { + icon = "fas fa-hand", + label = "Pick Weed", + action = function() + if not progressbar(Lang.Weed.pick, 4000, 'uncuff') then return end + TriggerServerEvent("weed:pickupCane", loc) + end + }, loc) end end) @@ -50,26 +49,16 @@ RegisterNetEvent("weed:init", function() if not HasModelLoaded(hash) then LoadModel(hash) end if not v.taken then WeedPlant[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z-3.5, false, true, true) - Freeze(WeedPlant[k],true, v.heading) - exports['qb-target']:AddTargetEntity(WeedPlant[k], { - options = { - { - icon = "fas fa-hand", - label = "Pick Weed", - action = function() - if not progressbar(Lang.Weed.pick, 4000, 'uncuff') then return end - TriggerServerEvent("weed:pickupCane", k) - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - } - }, - distance = 2.5 - }) + Freeze(WeedPlant[k],true, v.heading) + AddSingleModel(WeedPlant[k], + { + icon = "fas fa-hand", + label = "Pick Weed", + action = function() + if not progressbar(Lang.Weed.pick, 4000, 'uncuff') then return end + TriggerServerEvent("weed:pickupCane", k) + end + }, k) end end end) @@ -98,234 +87,74 @@ AddEventHandler('onResourceStop', function(resourceName) end) CreateThread(function() + AddBoxZoneMulti('weeddry', Config.WeedDry, { + name = 'dryweed', + icon = "fas fa-sign-in-alt", + label = "Dry Weed", + distance = 1, + action = function() + if not ItemCheck('wetcannabis') then return end + if drying then + Notify(Lang.Weed.busy, "error") + else + local loc = GetEntityCoords(PlayerPedId()) + local weedplant = CreateObject("bkr_prop_weed_drying_01a", loc.x, loc.y+.2, loc.z, true, false) + drying = true + FreezeEntityPosition(weedplant, true) + Notify("Wait A little Bit To Dry", "success") + Wait(math.random(1000,5000)) + Notify("Take Down The Weed", "success") + AddSingleModel(weedplant, { + icon = "fas fa-sign-in-alt", + label = "Pick Up Weed", + action = function() + DeleteEntity(weedplant) + drying = false + TriggerServerEvent('md-drugs:server:dryoutweed') + end, + canInteract = function() + if hasJob() then return true end end + }, nil) + end + end, + canInteract = function() + if hasJob() then return true end end + }) +AddBoxZoneSingle('teleinweedout', Config.Teleout, { name = 'teleout', icon = "fas fa-sign-in-alt", label = "Enter Building", distance = 2.0, action = function() SetEntityCoords(PlayerPedId(),Config.Telein) end, + canInteract = function() if hasJob() then return true end end +}) +AddBoxZoneSingle('teleinweedin', Config.Telein, { name = 'teleout', icon = "fas fa-sign-in-alt", label = "Exit Building", distance = 2.0, action = function() SetEntityCoords(PlayerPedId(),Config.Teleout) end, + canInteract = function() if hasJob() then return true end end +}) +AddBoxZoneSingle('MakeButterCrafting', Config.MakeButter, {label = 'Open Butter Menu', action = function() lib.showContext('ButterCraft') end, icon = "fas fa-sign-in-alt", +canInteract = function() if hasJob() then return true end end +}) -for k, v in pairs (Config.WeedDry) do - -exports['qb-target']:AddBoxZone("weeddry"..k,v,1.5, 1.75, {name = "weeddry"..k,heading = 11.0,debugPoly = false,minZ = v.z-2,maxZ = v.z+2,}, { - options = { - { - name = 'dryweed', - icon = "fas fa-sign-in-alt", - label = "Dry Weed", - distance = 1, - item = "wetcannabis", - action = function() - if drying then - Notify(Lang.Weed.busy, "error") - else - local loc = GetEntityCoords(PlayerPedId()) - local weedplant = CreateObject("bkr_prop_weed_drying_01a", loc.x, loc.y+.2, loc.z, true, false) - drying = true - FreezeEntityPosition(weedplant, true) - Notify("Wait A little Bit To Dry", "success") - Wait(math.random(1000,5000)) - Notify("Take Down The Weed", "success") - local options = { - { - icon = "fas fa-sign-in-alt", - label = "Pick Up Weed", - action = function() - DeleteEntity(weedplant) - drying = false - TriggerServerEvent('md-drugs:server:dryoutweed') - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - } - } - local optionsox = { - { - icon = "fas fa-sign-in-alt", - label = "Pick Up Weed", - onSelect = function() - DeleteEntity(weedplant) - drying = false - TriggerServerEvent('md-drugs:server:dryoutweed') - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - } - } - if Config.oxtarget then - exports.ox_target:addLocalEntity(weedplant, optionsox ) - else - exports['qb-target']:AddTargetEntity(weedplant, {options = options}) - end - end - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - if drying == false then - return true end end - else - return true end end, - }, - }, -}) -end -exports['qb-target']:AddBoxZone("teleinweed",Config.Telein,1.5, 1.75, {name = "teleinweed",heading = 11.0,debugPoly = false,minZ = Config.Telein.z-2,maxZ = Config.Telein.z+2,}, { - options = { - { name = 'teleout', icon = "fas fa-sign-in-alt", label = "Enter Building", distance = 2.0, - action = function() - SetEntityCoords(PlayerPedId(),Config.Teleout) - - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - }, -}) -exports['qb-target']:AddBoxZone("teleinweedout",Config.Teleout,1.5, 1.75, { name = "teleinweedout",heading = 11.0,debugPoly = false,minZ = Config.Teleout.z-2,maxZ = Config.Teleout.z+2,}, { -options = { - { name = 'teleout', icon = "fas fa-sign-in-alt", label = "Exit Building", distance = 2.0, - action = function() - SetEntityCoords(PlayerPedId(),Config.Telein) - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - }, -}) -exports['qb-target']:AddBoxZone("MakeButter",Config.MakeButter,1.5, 1.75, {name = "MakeButter",heading = 11.0,debugPoly = false,minZ = Config.MakeButter.z-2,maxZ = Config.MakeButter.z+2,}, { -options = { - { - name = 'butter', - icon = "fas fa-sign-in-alt", - label = "Make Butter", - action = function() - if not ItemCheck('mdbutter') and not ItemCheck('grindedweed') then return end - if not minigame(2, 8) then return end - if not progressbar(Lang.Weed.canna, 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:makebutter") - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - { - name = 'makebrownies', - icon = "fas fa-sign-in-alt", - label = "Make Brownies", - item = "cannabutter", - action = function() - if not ItemCheck('cannabutter') and not ItemCheck('flour') and not ItemCheck('chocolate') then return end - if not minigame(2, 8) then return end - if not progressbar(Lang.Weed.brown, 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:makebrownies") - - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - { - name = 'makecookies', - icon = "fas fa-sign-in-alt", - label = "Make Cookies", - item = "cannabutter", - action = function() - if not ItemCheck('cannabutter') and not ItemCheck('flour') then return end - if not minigame(2, 8) then return end - if not progressbar(Lang.Weed.cook, 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:makecookies") - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - { - name = 'makechocolate', - icon = "fas fa-sign-in-alt", - label = "Make Chocolate", - item = "cannabutter", - action = function() - if not ItemCheck('cannabutter') and not ItemCheck('chocolate') then return end - if not minigame(2, 8) then return end - if not progressbar(Lang.Weed.choc, 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:makechocolate") - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - { - name = 'makemuffin', - icon = "fas fa-sign-in-alt", - label = "Make Muffin", - item = "cannabutter", - action = function() - if not ItemCheck('cannabutter') and not ItemCheck('flour') then return end - if not minigame(2, 8) then return end - if not progressbar(Lang.Weed.muff, 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:makemuffin") - end, - canInteract = function() - if Config.Joblock then - if QBCore.Functions.GetPlayerData().job.name == Config.weedjob then - return true end - else - return true end end, - }, - }, -}) -exports['qb-target']:AddBoxZone("makeoil",Config.MakeOil,1.5, 1.75, {name = "makeoil",heading = 11.0,debugPoly = false,minZ = Config.MakeOil.z-2,maxZ = Config.MakeOil.z+2,}, { -options = { - { - name = 'Oil', - icon = "fas fa-sign-in-alt", - label = "Make Oil", - action = function() - if not ItemCheck('butane') and not ItemCheck('grindedweed') then return end - if not minigame(2, 8) then - local explosion = math.random(1,100) - local loc = GetEntityCoords(PlayerPedId()) - if explosion <= 99 then - AddExplosion(loc.x, loc.y, loc.z, 49, 10, true, false, true, true) - exploded = true - Notify(Lang.Weed.stovehot, "error") - Wait(1000 * 30) - exploded = nil - end - return end - if not progressbar(Lang.Weed.shat, 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:makeoil") - end, - canInteract = function() - if exploded == nil then return true end - end, - }, - }, -}) +AddBoxZoneSingle('makeoil',Config.MakeOil, { + name = 'Oil', + icon = "fas fa-sign-in-alt", + label = "Make Oil", + action = function() + if not ItemCheckMulti({'butane', 'grindedweed'}) then return end + if not minigame(2, 8) then + local explosion = math.random(1,100) + local loc = GetEntityCoords(PlayerPedId()) + if explosion <= 99 then + AddExplosion(loc.x, loc.y, loc.z, 49, 10, true, false, true, true) + exploded = true + Notify(Lang.Weed.stovehot, "error") + Wait(1000 * 30) + exploded = nil + end + return end + if not progressbar(Lang.Weed.shat, 4000, 'uncuff') then return end + TriggerServerEvent("md-drugs:server:makeoil") + end, + canInteract = function() + if hasJob() and exploded == nil then return true end + end, +} ) end) CreateThread(function() @@ -352,29 +181,14 @@ CreateThread(function() FreezeEntityPosition(stove2, true) end) -RegisterNetEvent('md-drugs:client:bluntwraps', function(args) - lib.registerContext({ - id = 'bluntroll', - title = 'Blunt Types', - menu = 'bluntroll', - options = { - { title = 'Roll Blunt', description = 'Roll A Regular Blunt', icon = 'check', serverEvent = 'md-drugs:server:rollblunt'}, - { title = 'Dip Blunt Wrap In Lean', description = 'Roll A Lean Blunt', icon = 'check', serverEvent = 'md-drugs:server:rollleanblunt'}, - { title = 'Dip Blunt Wrap In Dextro', description = 'Roll A Dextro Blunt', icon = 'check', serverEvent = 'md-drugs:server:rolldextroblunt'}, - { title = 'Roll A Chewy Blunt', description = 'Roll A Chewy Blunt', icon = 'check', serverEvent = 'md-drugs:server:rollchewyblunt'}, - }, - }) - lib.showContext('bluntroll') -end) RegisterNetEvent("md-drugs:client:rollanim", function() if not progressbar(Lang.Weed.roll, 4000, 'uncuff') then return end end) + RegisterNetEvent("md-drugs:client:grind", function() if not progressbar("grinding", 4000, 'uncuff') then return end end) - - RegisterNetEvent("md-drugs:client:dodabs", function() if not progressbar('Doing Dabs', 4000, 'bong2') then return end @@ -387,27 +201,120 @@ local current = "u_m_m_jesus_01" lib.requestModel(current, Config.RequestModelTime) local CurrentLocation = Config.WeedSaleman - local WeedGuy = CreatePed(0,current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false) - Freeze(WeedGuy, true, CurrentLocation.w) - exports['qb-target']:AddTargetEntity(WeedGuy, { - options = { - {label = "Weed Shop",icon = "fas fa-eye",action = function() lib.showContext('WeedShop')end}, - } - }) -for k, v in pairs (Config.Weed.items) do - WeedShop[#WeedShop + 1] = { - icon = GetImage(v.name), - title = GetLabel(v.name), - description = '$'.. v.price, - event = "md-drugs:client:travellingmerchantox", - args = { - item = v.name, - cost = v.price, - amount = v.amount, - table = Config.Weed.items, - num = k, + local WeedGuy = CreatePed(0,current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.h, false, false) + Freeze(WeedGuy, true, CurrentLocation.h) + AddSingleModel(WeedGuy, {label = "Weed Shop",icon = "fas fa-eye",action = function() lib.showContext('WeedShop')end}, nil) + for k, v in pairs (Config.Weed.items) do + WeedShop[#WeedShop + 1] = { + icon = GetImage(v.name), + title = GetLabel(v.name), + description = '$'.. v.price, + event = "md-drugs:client:travellingmerchantox", + args = { + item = v.name, + cost = v.price, + amount = v.amount, + table = Config.Weed.items, + num = k, + } } - } - lib.registerContext({id = 'WeedShop',title = "Weed Shop", options = WeedShop}) + lib.registerContext({id = 'WeedShop',title = "Weed Shop", options = WeedShop}) end end) + +CreateThread(function() +local items = lib.callback.await('md-drugs:server:GetRecipe', false,'weed', 'edibles') +local items2 = lib.callback.await('md-drugs:server:GetRecipe', false,'weed', 'blunts') +local items3 = lib.callback.await('md-drugs:server:GetRecipe', false,'weed', 'bluntwrap') +local craft = {} +local blunt = {} +local bluntwrap = {} +local label = {} +for k, v in pairs (items) do + label = {} + local item = '' + for m, d in pairs (items[k].take) do + table.insert(label, GetLabel(m) .. ' X ' .. d) + end + for m,d in pairs (items[k].give) do + item = m + end + craft[#craft + 1] = { + icon = GetImage(item), + description = table.concat(label, ", "), + title = GetLabel(item), + event = "md-drugs:client:MakeWeedItems", + args = { + item = item, + recipe = 'weed', + num = k, + label = 'Cooking Up ' .. GetLabel(item), + table = 'edibles' + + } + } + lib.registerContext({id = 'ButterCraft',title = "Edible Cooking", options = craft}) +end +for k, v in pairs (items2) do + label = {} + local item = '' + for m, d in pairs (items2[k].take) do + table.insert(label, GetLabel(m) .. ' X ' .. d) + end + for m, d in pairs (items2[k].give) do + item = m + end + blunt[#blunt + 1] = { + icon = GetImage(item), + description = table.concat(label, ", "), + title = GetLabel(item), + event = "md-drugs:client:MakeWeedItems", + args = { + item = item, + recipe = 'weed', + num = k, + label = 'Rolling A ' .. GetLabel(item), + table = 'blunts' + } + } + lib.registerContext({id = 'mddrugsblunts',title = "Roll Blunts", options = blunt}) +end +for k, v in pairs (items3) do + label = {} + local item = '' + for m, d in pairs (items3[k].take) do + table.insert(label, GetLabel(m) .. ' X ' .. d) + end + for m,d in pairs (items3[k].give) do + item = m + end + bluntwrap[#bluntwrap + 1] = { + icon = GetImage(item), + description = table.concat(label, ", "), + title = GetLabel(item), + event = "md-drugs:client:MakeWeedItems", + args = { + item = item, + recipe = 'weed', + num = k, + label = 'Dipping Syrup To Make ' .. GetLabel(item), + table = 'bluntwrap' + } + } + lib.registerContext({id = 'mddrugsbluntwraps',title = "Dip Blunt Wrap", options = bluntwrap}) +end +end) + +RegisterNetEvent("md-drugs:client:MakeWeedItems", function(data) + if not minigame() then return end + if not progressbar('Making ' .. data.item, 4000, 'uncuff') then return end + TriggerServerEvent('md-drugs:server:MakeWeedItems', data) +end) + +RegisterNetEvent('md-drugs:client:makeBluntWrap', function(data) + lib.showContext('mddrugsbluntwraps') +end) + +RegisterNetEvent('md-drugs:client:rollBlunt', function(data) + lib.showContext('mddrugsblunts') +end) diff --git a/client/wholesale.lua b/client/wholesale.lua index 91ee2c3..5c5579c 100644 --- a/client/wholesale.lua +++ b/client/wholesale.lua @@ -9,7 +9,6 @@ RegisterNetEvent("md-drugs:client:GetLocation", function(drug, notify) else TriggerServerEvent('md-drugs:server:RemoveBurner', drug) Notify(notify, 'success') - local unlucky = math.random(1,100) local CurrentLocation = Config.oxylocations[math.random(#Config.oxylocations)] local timer = 0 miss = true @@ -23,48 +22,40 @@ RegisterNetEvent("md-drugs:client:GetLocation", function(drug, notify) AddTextComponentSubstringPlayerName("drug Meet") EndTextCommandSetBlipName(deliveryBlip) SetBlipRoute(deliveryBlip, true) + lib.requestModel("g_m_y_famdnf_01", Config.RequestModelTime) + local current = "g_m_y_famdnf_01" + local drugdealer = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, 90.0, false, false) + FreezeEntityPosition(drugdealer, true) + SetEntityInvincible(drugdealer, true) + AddSingleModel(drugdealer, { + type = "client", + label = "Talk To Buyer", + icon = "fas fa-eye", + action = function() + local luck = math.random(1,100) + if luck >=101 then + TriggerEvent("md-drugs:client:SuccessSale", drug) + Wait(4000) + DeleteEntity(drugdealer) + else + TriggerEvent("md-drugs:client:SetUp") + Wait(3000) + DeleteEntity(drugdealer) + end + miss = false + end, + },nil ) repeat Wait(1000) timer = timer + 1 until #(GetEntityCoords(PlayerPedId()) - vector3(CurrentLocation.x, CurrentLocation.y, CurrentLocation.z) ) < 4.0 or timer == Config.WholesaleTimeout + 1 PoliceCall(Config.AlertPoliceWholesale) + RemoveBlip(deliveryBlip) if timer <= Config.WholesaleTimeout or #(GetEntityCoords(PlayerPedId()) - vector3(CurrentLocation.x, CurrentLocation.y, CurrentLocation.z) ) < 4.0 then timer = 0 - RemoveBlip(deliveryBlip) - lib.requestModel("g_m_y_famdnf_01", Config.RequestModelTime) - local current = "g_m_y_famdnf_01" - local drugdealer = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, 90.0, false, false) - FreezeEntityPosition(drugdealer, true) - SetEntityInvincible(drugdealer, true) - exports['qb-target']:AddTargetEntity(drugdealer, { - options = { - { - type = "client", - label = "Talk To Buyer", - icon = "fas fa-eye", - action = function() - local luck = math.random(1,100) - local ped = GetEntityCoords(PlayerPedId()) - if luck <= Config.SuccessfulChance then - TriggerEvent("md-drugs:client:SuccessSale", drug) - Wait(4000) - DeleteEntity(drugdealer) - else - TriggerEvent("md-drugs:client:SetUp") - Wait(3000) - SetUpPeds() - Wait(4000) - DeleteEntity(drugdealer) - end - miss = false - end, - }, - }, - distance = 2.0 - }) else Notify('The Buyer Waited To Long') - RemoveBlip(deliveryBlip) + DeleteEntity(drugdealer) end end end) diff --git a/client/xtc.lua b/client/xtc.lua index 9ac9470..2909490 100644 --- a/client/xtc.lua +++ b/client/xtc.lua @@ -3,23 +3,26 @@ local xtcpress = false RegisterNetEvent("md-drugs:client:setpress", function(type) - if xtcpress then Notify(Lang.xtc.out, 'error') else - local PedCoords = GetEntityCoords(PlayerPedId()) + local coords, head = StartRay2() xtcpress = true progressbar('Setting Press On The Ground', 4000, 'uncuff') - local press = CreateObject("bkr_prop_coke_press_01aa", PedCoords.x+1, PedCoords.y+1, PedCoords.z-1, true, false) + local press = CreateObject("bkr_prop_coke_press_01aa", coords.x, coords.y, coords.z, true, false, false) PlaceObjectOnGroundProperly(press) - + SetEntityHeading(press, head) local options = { - { + { icon = "fas fa-eye", label = "Make XTC", + distance = 2.0, action = function() TriggerEvent("md-drugs:client:XTCMenu", type) end, + onSelect = function() + TriggerEvent("md-drugs:client:XTCMenu", type) + end, canInteract = function() if xtcpress then return true end end }, @@ -28,36 +31,16 @@ RegisterNetEvent("md-drugs:client:setpress", function(type) label = "Pick Up", action = function() TriggerEvent("md-drugs:client:GetPressBack", type, press) - end, - canInteract = function() - if xtcpress then return true end end - }, - } - local optionsox = { - { - icon = "fas fa-eye", - label = "Make XTC", - onSelect = function() - TriggerEvent("md-drugs:client:XTCMenu", type) - end, - canInteract = function() - if xtcpress then return true end end - }, - { - icon = "fas fa-eye", - label = "Pick Up", + end, onSelect = function() TriggerEvent("md-drugs:client:GetPressBack", type, press) - end, + end, + distance = 2.0, canInteract = function() if xtcpress then return true end end }, } - if Config.oxtarget then - exports.ox_target:addLocalEntity(press, optionsox) - else - exports['qb-target']:AddTargetEntity(press, { options = options}) - end + AddMultiModel(press, options, nil) end end) @@ -196,7 +179,7 @@ RegisterNetEvent("md-drugs:client:exchangepresses", function(data) end) RegisterNetEvent("md-drugs:client:buypress", function() - local img = GetImage('singlepress'), + local img = GetImage('singlepress') lib.registerContext({ id = 'buypresses', title = 'Purchase Presses', diff --git a/patchnotes.txt b/patchnotes.txt index b01471d..b67b5b2 100644 --- a/patchnotes.txt +++ b/patchnotes.txt @@ -41,3 +41,63 @@ should be fully compatible with qbx without needing to make a couple edits now Added support for fivemerr logs 3.5.8 -> 3.5.9 added command /cornersell **you only need to update server/cornserselling.lua** from previous update + +3.5.9 - > 3.7.0 + +im bad at numbers sue me kek + +a lot has been changed with this version +The main thing to update from 3.5.9 to 3.7.0 is a couple things in your config +SAVE YOUR SHARED FOLDER AND COPY AND PASTE IT TO YOUR DESKTOP SO YOU HAVE A SECOND COPY + +``` +Config.oxtarget: + no longer exists in new version. Change it to + +Config.Target = 'qb' -- qb or ox + +Config.minigametype: +changed a little bit. you need to add this table to make things work now + +Config.Minigames = { + ps = { amount = 2, speed = 8,}, + ox = { 'easy', 'easy'}, --easy medium or hard each one corresponds to how many skillchecks and the difficulty + blcirprog = { amount = 2, speed = 50}, -- speed = 1-100 + blprog = { amount = 1, speed = 50}, -- speed = 1-100 + blkeyspam = { amount = 1, difficulty = 50}, -- difficulty = 1-100 + blkeycircle = { amount = 1, difficulty = 50, keynumbers = 3}, + blnumberslide = { amount = 1, difficulty = 50, keynumbers = 3}, + blrapidlines = { amount = 1, difficulty = 50, numberofline = 3}, + blcircleshake = { amount = 1, difficulty = 50, stages = 3}, + glpath = { gridsize = 10, lives = 3, timelimit = 999999}, + glspot = {gridSize = 6, timeLimit = 999999, charSet = "alphabet", required = 10}, + glmath = {timeLimit = 300000}, + +} + +what does this do, adds 10 more minigames than before you can use. How to set it, change Config.minigametype to the key of that table like ps ox blcirprog + +``` + +Now thats the config changes so you dont need to reconfig everything as I do my best to not change much in the config and work around what has been done + +Whats been added +``` +i moved tier system to SQL as its better than using metadata +run the SQL and it will autopopulate your metadata for rep so people wont lose anything + +I added a new sql table for deliveries + +it not checks overall time for deliveries regardless if you crash or not. + +Added new server file called recipes.lua + +its what you imagine, about 80-90% of the recipes for md-drugs + +``` + +Is there bugs, probably. But im tired of beta testing it over and over so please report bugs to my discord where i can see them and patch them quickly. + + + + diff --git a/readme.md b/readme.md index 659a546..36158c0 100644 --- a/readme.md +++ b/readme.md @@ -145,7 +145,8 @@ then in prop emotes do } ``` - +- **STEP 6** +Run SQL -- **OPTIONAL STEPS** diff --git a/server/cocaine.lua b/server/cocaine.lua index 6115b3d..171c731 100644 --- a/server/cocaine.lua +++ b/server/cocaine.lua @@ -21,130 +21,101 @@ end RegisterNetEvent("coke:pickupCane") AddEventHandler("coke:pickupCane", function(loc) - local playerPed = GetPlayerPed(source) - - if CheckDist(source, playerPed, Config.CocaPlant[loc].location) then return end + local src = source + if CheckDist(src, Config.CocaPlant[loc].location) then return end if not Config.CocaPlant[loc].taken then Config.CocaPlant[loc].taken = true GlobalState.CocaPlant = Config.CocaPlant TriggerClientEvent("coke:removeCane", -1, loc) CaneCooldown(loc) - local Player = QBCore.Functions.GetPlayer(source) - AddItem('coca_leaf', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked A Coca Leaf With a distance of ' .. dist(source, playerPed, Config.CocaPlant[loc].location) .. ' vectors', 'coke') + AddItem(src, 'coca_leaf', 1) + Log(GetName(src) .. ' Picked A Coca Leaf With a distance of ' .. dist(src, Config.CocaPlant[loc].location) .. ' vectors', 'coke') end end) - RegisterServerEvent('md-drugs:server:makepowder', function(num) local src = source - local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.MakePowder[num]['loc']) then return end - if not Itemcheck(Player, 'coca_leaf', 1, 'true') then return end + if CheckDist(src, Config.MakePowder[num]['loc']) then return end if Config.TierSystem then - local coke = Player.PlayerData.metadata['coke'] + local coke = getRep(src, 'coke') if coke <= Config.Tier1 then - if RemoveItem("coca_leaf", 1) then - AddItem("coke", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Raw Coke' .. dist(source, playerPed, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - end + if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier1') then return end + Log(GetName(src) .. ' Made Raw Coke' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') elseif coke >= Config.Tier1 and coke <= Config.Tier2 then - if RemoveItem("coca_leaf", 1) then - AddItem("cokestagetwo", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Raw Coke tier 2' .. dist(source, playerPed, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - end - + if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier2') then return end + Log(GetName(src) .. ' Made Raw Coke tier 2' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') else - if RemoveItem("coca_leaf", 1) then - AddItem("cokestagethree", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Raw Coke tier 3' .. dist(source, playerPed, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - end + if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier3') then return end + Log(GetName(src) ..' Made Raw Coke tier 3' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') end else - if RemoveItem("coca_leaf", 1) then - AddItem("coke", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Raw Coke' .. dist(source, playerPed, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - end - end + if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier1') then return end + Log(GetName(src) .. ' Made Raw Coke' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') + end end) - RegisterServerEvent('md-drugs:server:cutcokeone', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player,'bakingsoda', 1, 'true') then return end + local Player = QBCore.Functions.GetPlayer(src) if Config.TierSystem then local coke = Player.Functions.GetItemByName('coke') local coke2 = Player.Functions.GetItemByName('cokestagetwo') local coke3 = Player.Functions.GetItemByName('cokestagethree') if coke then - RemoveItem('coke', 1 ) - RemoveItem('bakingsoda', 1 ) - AddItem('loosecoke', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Coke', 'coke') + if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end + Log(GetName(src) .. ' Cut Coke', 'coke') elseif coke2 then - RemoveItem('cokestagetwo', 1 ) - RemoveItem('bakingsoda', 1 ) - AddItem('loosecokestagetwo', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Coke tier 2', 'coke') + if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier2') then return end + Log(GetName(src) .. ' Cut Coke tier 2', 'coke') elseif coke3 then - RemoveItem('cokestagethree', 1 ) - RemoveItem('bakingsoda', 1 ) - AddItem('loosecokestagethree', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Coke tier 3', 'coke') + if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier3') then return end + Log(GetName(src) .. ' Cut Coke tier 3', 'coke') else - Notifys(Lang.Coke.nocutcoke, "error") + Notifys(src,Lang.Coke.nocutcoke, "error") end else - if RemoveItem('coke', 1 ) then - RemoveItem('bakingsoda', 1 ) - AddItem('loosecoke', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Coke', 'coke') - else - Notifys(Lang.Coke.nocutcoke, "error") - end + if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end + Log(GetName(src) .. ' Cut Coke', 'coke') end end) RegisterServerEvent('md-drugs:server:bagcoke', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'empty_weed_bag', 1, 'true') then return end + local Player = QBCore.Functions.GetPlayer(src) if Config.TierSystem then - local coke = Player.PlayerData.metadata['coke'] + local coke = getRep(source, 'coke') local locoke = Player.Functions.GetItemByName('loosecoke') local locoke2 = Player.Functions.GetItemByName('loosecokestagetwo') local locoke3 = Player.Functions.GetItemByName('loosecokestagethree') if locoke then - RemoveItem('loosecoke', 1 ) - RemoveItem('empty_weed_bag', 1) - AddItem('cokebaggy', 1) - Player.Functions.SetMetaData('coke', (coke + 1)) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Coke and now has a rep of ' .. coke + 1, 'coke') + if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end + AddRep(src, 'coke') + Log(GetName(src) .. ' Bagged Coke and now has a rep of ' .. coke + 1, 'coke') elseif locoke2 then - RemoveItem('loosecokestagetwo', 1 ) - RemoveItem('empty_weed_bag', 1) - AddItem('cokebaggystagetwo', 1) - Player.Functions.SetMetaData('coke', (coke + 1)) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Coke tier 2 and now has a rep of ' .. coke + 1, 'coke') + if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end + AddRep(src, 'coke') + Log(GetName(src) .. ' Bagged Coke tier 2 and now has a rep of ' .. coke + 1, 'coke') elseif locoke3 then - RemoveItem('loosecokestagethree', 1 ) - RemoveItem('empty_weed_bag', 1) - AddItem('cokebaggystagethree', 1) - Player.Functions.SetMetaData('coke', (coke + 1)) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Coke tier 3 and now has a rep of ' .. coke + 1, 'coke') + if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier3') then return end + AddRep(src, 'coke') + Log(GetName(source) .. ' Bagged Coke tier 3 and now has a rep of ' .. coke + 1, 'coke') else - Notifys(Lang.Coke.nobagcoke, "error") + Notifys(src, Lang.Coke.nobagcoke, "error") end else - if RemoveItem('loosecoke', 1 ) then - RemoveItem('empty_weed_bag', 1) - AddItem('cokebaggy', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Coke', 'coke') - else - Notifys(Lang.Coke.nobagcoke, "error") - end + if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end + Log(GetName(source) .. ' Bagged Coke', 'coke') end end) +local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3} +for k, v in pairs (cokecut) do + QBCore.Functions.CreateUseableItem(k, function(source, item) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + if Player.Functions.GetItemByName(item.name) then + if not Itemcheck(src, 'bakingsoda', 1) then return end + TriggerClientEvent('md-drugs:client:minusTier', src, {type = 'coke', xt = 'bakingsoda', item = k, amount = v,recieve = 'loosecoke'}) + end + end) +end \ No newline at end of file diff --git a/server/consumables.lua b/server/consumables.lua index ac7618e..d4fa8b5 100644 --- a/server/consumables.lua +++ b/server/consumables.lua @@ -15,9 +15,8 @@ end RegisterNetEvent('md-drugs:server:removeconsum', function(item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - Player.Functions.RemoveItem(item, 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got High With ' .. item .. '!', 'consuming') + RemoveItem(source,item, 1) + Log(GetName(source) .. ' Got High With ' .. item .. '!', 'consuming') end) RegisterNetEvent('md-drugs:server:updatestatus', function(stat, statval) diff --git a/server/cornerselling.lua b/server/cornerselling.lua index b4fbc28..fbedc37 100644 --- a/server/cornerselling.lua +++ b/server/cornerselling.lua @@ -1,21 +1,22 @@ local QBCore = exports['qb-core']:GetCoreObject() -local StolenDrugs = {} lib.callback.register('md-drugs:server:cornerselling:getAvailableDrugs', function(source, cb) - local AvailableDrugs = {} local Player = QBCore.Functions.GetPlayer(source) if not Player then return nil end local type = 0 - for k in pairs(QBConfig.DrugsPrice) do + for k, v in pairs(QBConfig.DrugsPrice) do local item = Player.Functions.GetItemByName(k) if item and type == 0 then type = type + 1 - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Allowed To Sell ' .. item.name .. '!' , 'cornerselling') - return item.name, item.amount + Log(GetName(source) .. ' Allowed To Sell ' .. item.name .. '!' , 'cornerselling') + local amount = math.random(1,item.amount) + if amount >= 15 then amount = 15 end + local price = math.random(QBConfig.DrugsPrice[k]['min'], QBConfig.DrugsPrice[k]['max']) * amount + return item.name, amount, price end end if type == 0 then - return 'nothing', 0 + return 'nothing', 0, 0 end end) @@ -23,9 +24,8 @@ end) RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price) local src = source local Player = QBCore.Functions.GetPlayer(src) - - if RemoveItem(item, amount) then - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Sold ' .. amount .. ' Of ' .. item .. ' For A Price Of ' .. price .. '!' , 'cornerselling') + if RemoveItem(src, item, amount) then + Log(GetName(src) .. ' Sold ' .. amount .. ' Of ' .. item .. ' For A Price Of ' .. price .. '!' , 'cornerselling') if QBConfig.MarkedBills then if price >= QBConfig.DrugsPrice[item]['min'] * amount and price <= QBConfig.DrugsPrice[item]['max'] * amount then local info = { @@ -34,27 +34,13 @@ RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price Player.Functions.AddItem('markedbills', 1, false, info ) end elseif QBConfig.CustomDirtyMoney then - Player.Functions.AddItem(QBConfig.CustomDirtyMoneyitem,price) + AddItem(src, QBConfig.CustomDirtyMoneyitem, price) else Player.Functions.AddMoney('cash', price) end end end) -RegisterNetEvent('md-drugs:server:robCornerDrugs', function(drugType, amount) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local availableDrugs = getAvailableDrugs(src) - - if not availableDrugs or not Player then return end - - local item = availableDrugs[drugType].item - - Player.Functions.RemoveItem(item, amount) - table.insert(StolenDrugs, {item = item, amount = amount}) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove", amount) - TriggerClientEvent('md-drugs:client:refreshAvailableDrugs', src, getAvailableDrugs(src)) -end) lib.addCommand('cornersell', { help = 'Sell Things On The Corner', params = { @@ -63,6 +49,6 @@ lib.addCommand('cornersell', { }, function(source, args, raw) local src = source local Player = QBCore.Functions.GetPlayer(source) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Used Command cornersell!' , 'cornerselling') + Log(GetName(source) .. ' Used Command cornersell!' , 'cornerselling') TriggerClientEvent('md-drugs:client:cornerselling', src) end) diff --git a/server/crack.lua b/server/crack.lua index 0495059..6652f9c 100644 --- a/server/crack.lua +++ b/server/crack.lua @@ -4,85 +4,63 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('md-drugs:server:makecrackone', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.makecrack[num]['loc']) then end - if not Itemcheck(Player, 'bakingsoda', 1, 'true') then return end + if CheckDist(src, Config.makecrack[num]['loc']) then return end if Config.TierSystem then local locoke = Player.Functions.GetItemByName('loosecoke') local locoke2 = Player.Functions.GetItemByName('loosecokestagetwo') local locoke3 = Player.Functions.GetItemByName('loosecokestagethree') if locoke then - RemoveItem('loosecoke', 1 ) - RemoveItem('bakingsoda', 1) - AddItem('crackrock', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Crack', 'crack') + if not GetRecipe(src, 'crack', 'cookcrack', 'tier1') then return end + Log(GetName(src) .. ' Cut Crack', 'crack') elseif locoke2 then - RemoveItem('loosecokestagetwo', 1 ) - RemoveItem('bakingsoda', 1) - AddItem('crackrockstagetwo', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Crack', 'crack') + if not GetRecipe(src, 'crack', 'cookcrack', 'tier2') then return end + Log(GetName(src) .. ' Cut Crack', 'crack') elseif locoke3 then - RemoveItem('loosecokestagethree', 1 ) - RemoveItem('bakingsoda', 1) - AddItem('crackrockstagethree', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Crack', 'crack') + if not GetRecipe(src, 'crack', 'cookcrack', 'tier3') then return end + Log(GetName(src) .. ' Cut Crack', 'crack') else - Notifys(Lang.Crack.nocoke, 'error') + Notifys(src,Lang.Crack.nocoke, 'error') end else - if RemoveItem('loosecoke', 1 ) then - RemoveItem('bakingsoda', 1) - AddItem('crackrock', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Crack', 'crack') - else - Notifys(Lang.Crack.nocoke, 'error') - end + if not GetRecipe(src, 'crack', 'cookcrack', 'tier1') then return end + Log(GetName(src) .. ' Cut Crack', 'crack') end end) RegisterServerEvent('md-drugs:server:bagcrack', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.bagcrack[num]['loc']) then return end - if not Itemcheck(Player, 'empty_weed_bag', 1, 'true') then return end + if CheckDist(src, Config.bagcrack[num]['loc']) then return end if Config.TierSystem then local rock = Player.Functions.GetItemByName('crackrock') local rock2 = Player.Functions.GetItemByName('crackrockstagetwo') local rock3 = Player.Functions.GetItemByName('crackrockstagethree') if rock then - RemoveItem('crackrock', 1 ) - RemoveItem('empty_weed_bag', 1) - AddItem('baggedcracked', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Crack', 'crack') + if not GetRecipe(src, 'crack', 'bagcrack', 'tier1') then return end + Log(GetName(src) .. ' Bagged Crack', 'crack') elseif rock2 then - RemoveItem('crackrockstagetwo', 1 ) - RemoveItem('empty_weed_bag', 1) - AddItem('baggedcrackedstagetwo', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Crack', 'crack') + if not GetRecipe(src, 'crack', 'bagcrack', 'tier2') then return end + Log(GetName(src) .. ' Bagged Crack', 'crack') elseif rock3 then - RemoveItem('crackrockstagethree', 1 ) - RemoveItem('empty_weed_bag', 1) - AddItem('baggedcrackedstagethree', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Crack', 'crack') + if not GetRecipe(src, 'crack', 'bagcrack', 'tier3') then return end + Log(GetName(src) .. ' Bagged Crack', 'crack') else - Notifys(Lang.Crack.nocoke, "error") + Notifys(src, Lang.Crack.nocoke, "error") end else - if RemoveItem('crackrock', 1 ) then - RemoveItem('empty_weed_bag', 1) - AddItem('baggedcracked', 1) - Notifys(Lang.Crack.makecrack, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged Crack', 'crack') - else - Notifys(Lang.Crack.nocoke, "error") - end + if not GetRecipe(src, 'crack', 'bagcrack', 'tier1') then return end + Log(GetName(src) .. ' Bagged Crack', 'crack') end -end) \ No newline at end of file +end) + +local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3} +for k, v in pairs (cokecut) do + QBCore.Functions.CreateUseableItem(k, function(source, item) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + if Player.Functions.GetItemByName(item.name) then + if not Itemcheck(src, 'bakingsoda', 1) then return end + TriggerClientEvent('md-drugs:client:minusTier', src, {type = 'crack', xt = 'bakingsoda', item = k, amount = v,recieve = 'crackrock'}) + end + end) +end \ No newline at end of file diff --git a/server/deliveries.lua b/server/deliveries.lua index 40f3d7a..5ee95d2 100644 --- a/server/deliveries.lua +++ b/server/deliveries.lua @@ -1,128 +1,65 @@ QBCore = exports['qb-core']:GetCoreObject() --- Functions -exports('GetDealers', function() - return QBConfig.Dealers -end) -- Callbacks -QBCore.Functions.CreateCallback('md-drugs:server:RequestConfig', function(_, cb) - cb(QBConfig.Dealers) -end) - --- Events -RegisterNetEvent('md-drugs:server:updateDealerItems', function(itemData, amount, dealer) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if not Player then return end - - if QBConfig.Dealers[dealer]["products"][itemData.slot].amount - 1 >= 0 then - QBConfig.Dealers[dealer]["products"][itemData.slot].amount = QBConfig.Dealers[dealer]["products"][itemData.slot].amount - amount - TriggerClientEvent('md-drugs:client:setDealerItems', -1, itemData, amount, dealer) +lib.callback.register('md-drugs:server:getDealers', function(data) + local check = MySQL.query.await('SELECT * FROM dealers', {}) + local loc = json.encode({x = 899.98, y = -2603.24, z = 6.11, h = 176.12 }) + if not check[1] then + MySQL.insert('INSERT INTO dealers SET name = ?, coords = ?, time = ?, createdby = ?', {'MD', loc, 'any', 'code Newb'}) + return false else - Player.Functions.RemoveItem(itemData.name, amount) - Player.Functions.AddMoney('cash', amount * QBConfig.Dealers[dealer]["products"][itemData.slot].price) - TriggerClientEvent("QBCore:Notify", src, "none Left", "error") + return check + end +end) + + +lib.callback.register('md-drugs:server:GetDeliveryItem', function(data) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + local item = math.random(1, #QBConfig.DeliveryItems) + local amount = math.random(1,4) + local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {Player.PlayerData.citizenid}) + local locnum = math.random(1, #QBConfig.DeliveryLocations) + local coord = json.encode({ + x = math.floor(QBConfig.DeliveryLocations[locnum].coords.x * 100) / 100, + y = math.floor(QBConfig.DeliveryLocations[locnum].coords.y * 100) / 100, + z = math.floor(QBConfig.DeliveryLocations[locnum].coords.z * 100) / 100, + }) + if not check[1] then + MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?', + {Player.PlayerData.citizenid, json.encode({item = QBConfig.DeliveryItems[item].item, amount = amount}), os.time(), os.time() + (15 * 60), coord }) + AddItem(Player.PlayerData.source, QBConfig.DeliveryItems[item].item, amount) + return true, QBConfig.DeliveryItems[item].item, amount, coord + else + local time = os.time() + local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60) + + if timeout > 15 then MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {Player.PlayerData.citizenid}) Notifys(src, 'You Failed To Make It In Time!', 'error' ) return false end + Notifys(src,'You Already Have A Delivery To Make', 'error' ) return false, QBConfig.DeliveryItems[item].item, amount, coord end end) -RegisterNetEvent('md-drugs:server:giveDeliveryItems', function(deliveryData) +RegisterNetEvent('md-drugs:server:giveDeliveryItems', function(item, amount) local src = source local Player = QBCore.Functions.GetPlayer(src) - local item = QBConfig.DeliveryItems[deliveryData.item].item - - if Player.Functions.AddItem(item, deliveryData.amount) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add") - end -end) - -RegisterNetEvent('md-drugs:server:successDelivery', function(deliveryData, inTime) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local item = QBConfig.DeliveryItems[deliveryData.item].item - local itemAmount = deliveryData.amount - local payout = deliveryData.itemData.payout * itemAmount - local copsOnline = QBCore.Functions.GetDutyCount('police') - local curRep = Player.PlayerData.metadata["dealerrep"] - local invItem = Player.Functions.GetItemByName(item) - - - if inTime then - if invItem and invItem.amount >= itemAmount then -- on time correct amount - Player.Functions.RemoveItem(item, itemAmount) - if copsOnline > 0 then - local copModifier = copsOnline * QBConfig.PoliceDeliveryModifier - if QBConfig.UseMarkedBills then - local info = {worth = math.floor(payout * copModifier)} - Player.Functions.AddItem('markedbills', 1, false, info) - else - Player.Functions.AddMoney('cash', math.floor(payout * copModifier), 'drug-delivery') - end - else - if QBConfig.UseMarkedBills then - local info = {worth = payout} - Player.Functions.AddItem('markedbills', 1, false, info) - else - Player.Functions.AddMoney('cash', payout, 'drug-delivery') - end - end - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove") - TriggerClientEvent('QBCore:Notify', src, "You Got There In Time!", 'success') - SetTimeout(math.random(5000, 10000), function() - TriggerClientEvent('md-drugs:client:sendDeliveryMail', src, 'perfect', deliveryData) - Player.Functions.SetMetaData('dealerrep', (curRep + QBConfig.DeliveryRepGain)) - end) - else - TriggerClientEvent('QBCore:Notify', src, "Wheres The Rest Of It", 'error')-- on time incorrect amount - if invItem then - local newItemAmount = invItem.amount - local modifiedPayout = deliveryData.itemData.payout * newItemAmount - Player.Functions.RemoveItem(item, newItemAmount) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove") - Player.Functions.AddMoney('cash', math.floor(modifiedPayout / QBConfig.WrongAmountFee)) - end - SetTimeout(math.random(5000, 10000), function() - TriggerClientEvent('md-drugs:client:sendDeliveryMail', src, 'bad', deliveryData) - if curRep - 1 > 0 then - Player.Functions.SetMetaData('dealerrep', (curRep - QBConfig.DeliveryRepLoss)) - else - Player.Functions.SetMetaData('dealerrep', 0) - end - end) - end - else - if invItem and invItem.amount >= itemAmount then -- late correct amount - TriggerClientEvent('QBCore:Notify', src, "Where Were You Slow Ass", 'error') - Player.Functions.RemoveItem(item, itemAmount) - Player.Functions.AddMoney('cash', math.floor(payout / QBConfig.OverdueDeliveryFee), "delivery-drugs-too-late") - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove") - SetTimeout(math.random(5000, 10000), function() - TriggerClientEvent('md-drugs:client:sendDeliveryMail', src, 'late', deliveryData) - if curRep - 1 > 0 then - Player.Functions.SetMetaData('dealerrep', (curRep - QBConfig.DeliveryRepLoss)) - else - Player.Functions.SetMetaData('dealerrep', 0) - end - end) - else - if invItem then -- late incorrect amount - local newItemAmount = invItem.amount - local modifiedPayout = deliveryData.itemData.payout * newItemAmount - TriggerClientEvent('QBCore:Notify', src, "Late And Missing Product GZ You Suck", 'error') - Player.Functions.RemoveItem(item, itemAmount) - Player.Functions.AddMoney('cash', math.floor(modifiedPayout / QBConfig.OverdueDeliveryFee), "delivery-drugs-too-late") - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove") - SetTimeout(math.random(5000, 10000), function() - TriggerClientEvent('md-drugs:client:sendDeliveryMail', src, 'late', deliveryData) - if curRep - 1 > 0 then - Player.Functions.SetMetaData('dealerrep', (curRep - QBConfig.DeliveryRepLoss)) - else - Player.Functions.SetMetaData('dealerrep', 0) - end - end) + local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {Player.PlayerData.citizenid}) + if not check[1] then return end + local time = os.time() + local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60) + local itemData = json.decode(check[1].itemdata) + if timeout >= 15 then MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {Player.PlayerData.citizenid}) Notifys(source, 'You Failed To Make It In Time!', 'error' ) return end + if item ~= itemData.item then return end + if amount ~= itemData.amount then return end + if RemoveItem(src, item, amount) then + for k, v in pairs (QBConfig.DeliveryItems) do + if v.item == item then + local income = math.random(v.payout.min, v.payout.max) + Player.Functions.AddMoney('cash', income) + AddRep(src, 'dealerrep') end end + MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {Player.PlayerData.citizenid}) end end) @@ -173,61 +110,6 @@ QBCore.Commands.Add("deletedealer", "Delete a dealer (Admin Only)", {{ end end, "admin") -QBCore.Commands.Add("dealers", "View all dealers (Admin Only)", {}, false, function(source, _) - local DealersText = "" - if QBConfig.Dealers ~= nil and next(QBConfig.Dealers) ~= nil then - for _, v in pairs(QBConfig.Dealers) do - DealersText = DealersText .. "Name: " .. v["name"] .. "
" - end - TriggerClientEvent('chat:addMessage', source, { - template = '', - args = {} - }) - else - TriggerClientEvent('QBCore:Notify', source, "No Dealers", 'error') - end -end, "admin") - -QBCore.Commands.Add("dealergoto", "Teleport to a dealer (Admin Only)", {{ - name = "name", - help = "Dealer name" -}}, true, function(source, args) - local DealerName = tostring(args[1]) - if QBConfig.Dealers[DealerName] then - local ped = GetPlayerPed(source) - SetEntityCoords(ped, QBConfig.Dealers[DealerName]['coords']['x'], QBConfig.Dealers[DealerName]['coords']['y'], QBConfig.Dealers[DealerName]['coords']['z']) - TriggerClientEvent('QBCore:Notify', source, "TelePorted", {dealerName = DealerName}, 'success') - else - TriggerClientEvent('QBCore:Notify', source, "Doesnt Exist", 'error') - end -end, "admin") - -CreateThread(function() - Wait(500) - local dealers = MySQL.query.await('SELECT * FROM dealers', {}) - if dealers[1] then - for _, v in pairs(dealers) do - local coords = json.decode(v.coords) - local time = json.decode(v.time) - - QBConfig.Dealers[v.name] = { - ["name"] = v.name, - ["coords"] = { - ["x"] = coords.x, - ["y"] = coords.y, - ["z"] = coords.z - }, - ["time"] = { - ["min"] = time.min, - ["max"] = time.max - }, - ["products"] = QBConfig.Products - } - end - end - TriggerClientEvent('md-drugs:client:RefreshDealers', -1, QBConfig.Dealers) - -end) RegisterServerEvent("md-drugs:server:Dealershop", function(amount, value, item, info) local src = source local Player = QBCore.Functions.GetPlayer(src) local balance = Player.Functions.GetMoney(tostring(value)) diff --git a/server/functions.lua b/server/functions.lua index 239f670..952375f 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -1,5 +1,7 @@ local QBCore = exports['qb-core']:GetCoreObject() local notify = Config.Notify -- qb or ox + +------------------------------------------ logging stuff local logs = false local logapi = GetConvar("fivemerrLogs", "") local endpoint = 'https://api.fivemerr.com/v1/logs' @@ -20,6 +22,7 @@ else print'^1 logs disabled for md-drugs' end end) + function Log(message, type) if logs == false then return end local buffer = { @@ -42,6 +45,7 @@ if logs == false then return end buffer = nil end) end +---------------------------------------------------- inventory catcher local invname = '' CreateThread(function() if GetResourceState('ps-inventory') == 'started' then @@ -51,10 +55,21 @@ elseif GetResourceState('qb-inventory') == 'started' then else invname = 'inventory' end - end) -function Notifys(text, type) +local inventory = '' + +CreateThread(function() +if GetResourceState('ox_inventory') == 'started' then + inventory = 'ox' +else + inventory = 'qb' +end +end) +------------------------------------ functions +--- +--- +function Notifys(source, text, type) local src = source if notify == 'qb' then TriggerClientEvent("QBCore:Notify", src, text, type) @@ -63,94 +78,223 @@ function Notifys(text, type) elseif notify == 'okok' then TriggerClientEvent('okokNotify:Alert', src, '', text, 4000, type, false) else - print"dude, it literally tells you what to put in the config" + print"^1 Look At The Config For Proper Alert Options" end -end - -function Itemcheck(Player, item, amount, notify) - local itemchecks = Player.Functions.GetItemByName(item) - local yes - - if notify == nil then notify = false end - if itemchecks and itemchecks.amount >= amount then - yes = true return yes - else - if notify == 'true' then - Notifys('You Need ' .. amount .. ' Of ' .. QBCore.Shared.Items[item].label .. ' To Do this', 'error') return else end - end end -function dist(source, Player, coords) - local pcoords = GetEntityCoords(Player) + +function GetLabels(item) + if inventory == 'qb' then + return QBCore.Shared.Items[item].label + elseif inventory == 'ox' then + local items = exports.ox_inventory:Items() + return items[item].label + end +end + +function Itemcheck(source, item, amount) + if inventory == 'qb' then + local Player = QBCore.Functions.GetPlayer(source) + local itemchecks = Player.Functions.GetItemByName(item) + if itemchecks and itemchecks.amount >= amount then + return true + else + Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do this', 'error') + return false + end + elseif inventory == 'ox' then + local has = exports.ox_inventory:GetItem(source, item , nil, true) + if has.count >= amount then + return true + else + Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error') + return false + end + end +end + +function GetCoords(source) + local ped = GetPlayerPed(source) + local playerCoords = GetEntityCoords(ped) + return playerCoords +end + +function dist(source, coords) + local playerPed = GetPlayerPed(source) + local pcoords = GetEntityCoords(playerPed) local dist = #(pcoords - coords) return dist end -function CheckDist(source,Player, coords) - local pcoords = GetEntityCoords(Player) + +function CheckDist(source, coords) + local playerPed = GetPlayerPed(source) + local pcoords = GetEntityCoords(playerPed) local ok if #(pcoords - coords) < 4.0 then return ok else - DropPlayer(source, 'Too Far') return end + DropPlayer(source, 'md-drugs: You Were A Total Of ' .. #(pcoords - coords) .. ' Too Far Away To Trigger This Event') + return false + end end -function checkTable(player, table) + +function checkTable(table) local need = 0 local have = 0 for k, v in pairs (table) do need = need + 1 - if Itemcheck(player, k, v, 'true') then have = have + 1 end + if Itemcheck(source, k, v) then have = have + 1 end end if need == have then return true else end end -function RemoveItem( item, amount) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.RemoveItem(item, amount) then TriggerClientEvent(invname ..":client:ItemBox", src, QBCore.Shared.Items[item], "remove", amount) return true - else - Notifys('You Need ' .. amount .. ' Of ' .. QBCore.Shared.Items[item].label .. ' To Do This', 'error') + +function RemoveItem(source, item, amount) + if inventory == 'qb' then + local Player = QBCore.Functions.GetPlayer(source) + if Player.Functions.RemoveItem(item, amount) then + TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "remove", amount) + return true + else + Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error') + end + elseif inventory == 'ox' then + if exports.ox_inventory:RemoveItem(source, item, amount) then + return true + else + Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error') + end end end -function AddItem(item, amount) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.AddItem(item, amount) then TriggerClientEvent(invname ..":client:ItemBox", src, QBCore.Shared.Items[item], "add", amount) return true - else - print('you sucks') - end -end - -function Notifysu(text, type, source) - - if notify == 'qb' then - TriggerClientEvent("QBCore:Notify", source, text, type) - elseif notify == 'ox' then - lib.notify(source, { title = text, type = type}) - elseif notify == 'okok' then - TriggerClientEvent('okokNotify:Alert', source, '', text, 4000, type, false) +function AddItem(source, item, amount) + if inventory == 'qb' then + local Player = QBCore.Functions.GetPlayer(source) + if Player.Functions.AddItem(item, amount) then + TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "add", amount) + return true + else + print('Failed To Give Item: ' .. item .. ' Check Your qb-core/shared/items.lua') + return false + end else - print"dude, it literally tells you what to put in the config" - end -end - -function RemoveItemu( item, amount, source) - local Player = QBCore.Functions.GetPlayer(source) - if Player.Functions.RemoveItem(item, amount) then TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "remove", amount) return true - else - Notifysu('You Need ' .. amount .. ' Of ' .. QBCore.Shared.Items[item].label .. ' To Do This', 'error', source) + local carry = exports.ox_inventory:CanCarryItem(source, item, amount) + if not carry then Notifys(source, 'You Cant Carry that Much Weight!', 'error') return false end + if exports.ox_inventory:AddItem(source, item, amount) then + return true + else + print('Failed To Give Item: ' .. item .. ' Check Your ox_inventory/data/items.lua') + return false + end end end -function AddItemu(item, amount, source) - local Player = QBCore.Functions.GetPlayer(source) - if Player.Functions.AddItem(item, amount) then TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "add", amount) return true - else - print('you sucks') +function GetName(source) + local Player = QBCore.Functions.GetPlayer(source) + return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname + +end + +function getRep(source, type) + local Player = QBCore.Functions.GetPlayer(source) + local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid}) + if not sql[1] then + local table = json.encode({ + coke = Player.PlayerData.metadata.coke or 0, + lsd = Player.PlayerData.metadata.lsd or 0, + heroin = Player.PlayerData.metadata.heroin or 0, + dealerrep = Player.PlayerData.metadata.dealerrep or 0, + }) + MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {Player.PlayerData.citizenid, table, GetName(source)}) + return false + else + local rep = json.decode(sql[1].drugrep) + if type == 'coke' then + return rep.coke + elseif type == 'heroin' then + return rep.heroin + elseif type == 'lsd' then + return rep.lsd + elseif type == 'dealerrep' then + return rep.dealerrep + else + print('^1 Error: No Valid Drug Rep Option Chosen') + end + return false + end +end + +function GetAllRep(source) + local Player = QBCore.Functions.GetPlayer(source) + local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid}) + if not sql[1] then + local table = json.encode({ + coke = Player.PlayerData.metadata.coke or 0, + lsd = Player.PlayerData.metadata.lsd or 0, + heroin = Player.PlayerData.metadata.heroin or 0, + dealerrep = Player.PlayerData.metadata.dealerrep or 0, + }) + MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {Player.PlayerData.citizenid, table, GetName(source)}) + Wait(1000) + return false + else + local rep = json.decode(sql[1].drugrep) + return rep + end +end + +function AddRep(source, type) + local Player = QBCore.Functions.GetPlayer(source) + local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid}) + local rep = json.decode(sql[1].drugrep) + local update + if type == 'coke' then + update = json.encode({coke = rep.coke + 1, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep}) + elseif type == 'heroin' then + update = json.encode({coke = rep.coke, heroin = rep.heroin + 1, lsd = rep.lsd, dealerrep = rep.dealerrep}) + elseif type == 'lsd' then + update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd +1 , dealerrep = rep.dealerrep}) + elseif type == 'dealerrep' then + update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep + 1}) + end + if update == '' then return false end + MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, Player.PlayerData.citizenid}) + return true +end + + +function ChecknRemove(source, table) + local Player = QBCore.Functions.GetPlayer(source) + local hass = 0 + local need = 0 + for k, v in pairs (table) do + need = need + 1 + if inventory == 'qb' then + local itemchecks = Player.Functions.GetItemByName(k) + if itemchecks and itemchecks.amount >= v then + hass = hass + 1 + else + Notifys(source, 'You Need ' .. v .. ' Of ' .. GetLabels(k) .. ' To Do this', 'error') + end + elseif inventory == 'ox' then + local has = exports.ox_inventory:GetItem(source, k , nil, true) + if has.count >= v then + hass = hass + 1 + else + Notifys(source, 'You Need ' .. v .. ' Of ' .. GetLabels(k) .. ' To Do This', 'error') + end + end + end + if hass == need then + for k, v in pairs (table) do + RemoveItem(source, k, v) + end + return true + else + return false end end - lib.callback.register('md-drugs:server:GetCoppers', function(source, cb, args) local amount = 0 @@ -163,17 +307,20 @@ lib.callback.register('md-drugs:server:GetCoppers', function(source, cb, args) return amount end) +lib.callback.register('md-drugs:server:GetRep', function(source, cb, args) + local src = source + local rep = GetAllRep(source) + return rep +end) + CreateThread(function() if not GetResourceState('ox_lib'):find("start") then print('^1 ox_lib Is A Depndancy, Not An Optional ') end - if Config.minigametype == 'ps' and not GetResourceState('ps-ui'):find("start") then - print('^1 You Have Config.minigametype as ps but dont have ps-ui started') - end end) CreateThread(function() local url = "https://raw.githubusercontent.com/Mustachedom/md-drugs/main/version.txt" - local version = GetResourceMetadata('md-drugs', "version" ) + local version = GetResourceMetadata('md-drugs-expiramental', "version" ) PerformHttpRequest(url, function(err, text, headers) if (text ~= nil) then print('^2 Your Version:' .. version .. ' | Current Version:' .. text .. '' ) @@ -181,3 +328,11 @@ CreateThread(function() end, "GET", "", "") end) +RegisterServerEvent('md-drugs:server:AddMas', function(data) + local src = source + if not data then return end + if not Itemcheck(src, data.xt, 1) then return end + if not RemoveItem(src, data.item, 1) then return end + RemoveItem(src, data.xt, 1) + AddItem(src, data.recieve, data.amount) +end) \ No newline at end of file diff --git a/server/heroin.lua b/server/heroin.lua index e9547cd..3fd070e 100644 --- a/server/heroin.lua +++ b/server/heroin.lua @@ -22,63 +22,46 @@ end RegisterServerEvent('md-drugs:server:removecleaningkitheroin', function(data) local src = source -local Player = QBCore.Functions.GetPlayer(src) - - if RemoveItem("cleaningkit", 1) then - Notifys("Cleaned It Perfectly", "success") + if RemoveItem(src,"cleaningkit", 1) then TriggerClientEvent("md-drugs:client:deletedirtyheroin", src, data) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wiped Down Their Heroin Lab Kit!' , 'heroin') + Log(GetName(src) .. ' Wiped Down Their Heroin Lab Kit!' , 'heroin') else - Notifys("You cant clean it with spit alone", "error") + Notifys(src, "You cant clean it with spit alone", "error") end end) RegisterServerEvent("heroin:pickupCane", function(loc) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.PoppyPlants[loc].location) then return end + if CheckDist(source, Config.PoppyPlants[loc].location) then return end if not Config.PoppyPlants[loc].taken then Config.PoppyPlants[loc].taken = true GlobalState.PoppyPlants = Config.PoppyPlants TriggerClientEvent("heroin:removeCane", -1, loc) heroinCooldown(loc) - local Player = QBCore.Functions.GetPlayer(source) - AddItem('poppyresin', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked A Poppies With a distance of ' .. dist(source, playerPed, Config.PoppyPlants[loc].location) .. ' vectors', 'heroin') - + AddItem(source, 'poppyresin', 1) + Log(GetName(source) .. ' Picked A Poppies With a distance of ' .. dist(source, Config.PoppyPlants[loc].location) .. ' vectors', 'heroin') end end) RegisterServerEvent('md-drugs:server:dryplant', function(num) local src = source - local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.dryplant[num]['loc']) then return end - if not Itemcheck(Player, 'poppyresin', 1, 'true') then return end + if CheckDist(source, Config.dryplant[num]['loc']) then return end + if not Itemcheck(source, 'poppyresin', 1) then return end if Config.TierSystem then - local heroin = Player.PlayerData.metadata['heroin'] + local heroin = getRep(src, 'heroin') if heroin <= Config.Tier1 then - if RemoveItem("poppyresin", 1) then - AddItem("heroin", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Heroin Powder With a distance of ' .. dist(source, playerPed, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') - end + if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end + Log(GetName(src) ..' Made Heroin Powder With a distance of ' .. dist(source, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') elseif heroin >= Config.Tier1 and heroin <= Config.Tier2 then - if RemoveItem("poppyresin", 1) then - AddItem("heroinstagetwo", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Heroin Powder Tier 2 With a distance of ' .. dist(source, playerPed, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') - end + if not GetRecipe(src, 'heroin', 'dryheroin', 'tier2') then return end + Log(GetName(src) ..' Made Heroin Powder Tier 2 With a distance of ' .. dist(source, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') else - if RemoveItem("poppyresin", 1) then - AddItem("heroinstagethree", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Heroin Powder Tier 3 With a distance of ' .. dist(source, playerPed, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') - end + if not GetRecipe(src, 'heroin', 'dryheroin', 'tier3') then return end + Log(GetName(src) ..' Made Heroin Powder Tier 3 With a distance of ' .. dist(source, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') end else - if RemoveItem("poppyresin", 1) then - AddItem("heroin", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Heroin Powder With a distance of ' .. dist(source, playerPed, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') - - end + if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end + Log(GetName(src) ..' Made Heroin Powder With a distance of ' .. dist(source, Config.dryplant[num]['loc']) .. ' vectors', 'heroin') end end) @@ -86,78 +69,58 @@ end) RegisterServerEvent('md-drugs:server:cutheroin', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.cutheroinone[num]['loc']) then return end - if not Itemcheck(Player, 'bakingsoda', 1, 'true') then return end + if CheckDist(source, Config.cutheroinone[num]['loc']) then return end + if not Itemcheck(src, 'bakingsoda', 1) then return end if Config.TierSystem then local rawh = Player.Functions.GetItemByName('heroin') local rawh2 = Player.Functions.GetItemByName('heroinstagetwo') local rawh3 = Player.Functions.GetItemByName('heroinstagethree') if rawh then - RemoveItem('heroin', 1 ) - RemoveItem('bakingsoda', 1 ) - AddItem('heroincut',1) - Notifys(Lang.Heroin.cutheroin, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Heroin With a distance of ' .. dist(source, playerPed, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') + if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end + Log(GetName(src) ..' Cut Heroin With a distance of ' .. dist(source, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') elseif rawh2 then - RemoveItem('heroinstagetwo', 1 ) - RemoveItem('bakingsoda', 1 ) - AddItem('heroincutstagetwo', 1) - Notifys(Lang.Heroin.cutheroin, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Heroin Tier 2 With a distance of ' .. dist(source, playerPed, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') + if not GetRecipe(src, 'heroin', 'cutheroin', 'tier2') then return end + Log(GetName(src) ..' Cut Heroin Tier 2 With a distance of ' .. dist(source, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') elseif rawh3 then - RemoveItem('heroinstagethree', 1 ) - RemoveItem('bakingsoda', 1 ) - AddItem('heroincutstagethree', 1) - Notifys(Lang.Heroin.cutheroin, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Heroin Tier 3 With a distance of ' .. dist(source, playerPed, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') + if not GetRecipe(src, 'heroin', 'cutheroin', 'tier3') then return end + Log(GetName(src) .. ' Cut Heroin Tier 3 With a distance of ' .. dist(source, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') else - Notifys(Lang.Heroin.noheroin, "error") + Notifys(src, Lang.Heroin.noheroin, "error") end else - if RemoveItem('heroin', 1 ) then - RemoveItem('bakingsoda', 1 ) - AddItem('heroincut',1) - Notifys(Lang.Heroin.cutheroin, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Cut Heroin With a distance of ' .. dist(source, playerPed, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') - else - Notifys(Lang.Heroin.noheroin, "error") - end + if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end + Log(GetName(src) ..' Cut Heroin With a distance of ' .. dist(source, Config.cutheroinone[num]['loc']) .. ' vectors', 'heroin') end end) RegisterServerEvent('md-drugs:server:getheroinlabkit', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, vector3(Config.buyheroinlabkit.x,Config.buyheroinlabkit.y,Config.buyheroinlabkit.z)) then return end + if CheckDist(source, vector3(Config.buyheroinlabkit.x,Config.buyheroinlabkit.y,Config.buyheroinlabkit.z)) then return end if Player.Functions.RemoveMoney('cash', Config.heroinlabkitprice) then - AddItem('heroinlabkit', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bought A Heroin lab Kit ' .. dist(source, playerPed, vector3(Config.buyheroinlabkit.x,Config.buyheroinlabkit.y,Config.buyheroinlabkit.z)) .. ' vectors', 'heroin') + AddItem(src, 'heroinlabkit', 1) + Log(GetName(src) ..' Bought A Heroin lab Kit ' .. dist(source, vector3(Config.buyheroinlabkit.x,Config.buyheroinlabkit.y,Config.buyheroinlabkit.z)) .. ' vectors', 'heroin') else - Notifys('You Need '.. Config.heroinlabkitprice .. ' In Cash For This', 'error') + Notifys(src, 'You Need '.. Config.heroinlabkitprice .. ' In Cash For This', 'error') end end) RegisterServerEvent('md-drugs:server:getheroinlabkitback', function() local src = source local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(source) - if Player.Functions.AddItem("heroinlabkit", 1) then - Notifys('You Got Your Lab Kit Back', 'Success') - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Up Their Heroin Lab Kit Back At ' .. GetEntityCoords(playerPed) .. '!', 'heroin') + if AddItem(src, "heroinlabkit", 1) then + Log(GetName(src) ..' Picked Up Their Heroin Lab Kit Back At ' .. GetCoords(src) .. '!', 'heroin') end end) QBCore.Functions.CreateUseableItem('heroinlabkit', function(source, item) local src = source local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(src) - if not Itemcheck(Player, 'heroinlabkit', 1, 'true') then return end + if not Itemcheck(source, 'heroinlabkit', 1) then return end if TriggerClientEvent("md-drugs:client:setheroinlabkit", src) then - Player.Functions.RemoveItem("heroinlabkit", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Placed Their Heroin Lab Kit Back At ' .. GetEntityCoords(playerPed) .. '!', 'heroin') + RemoveItem(src, "heroinlabkit", 1) + Log(GetName(src) ..' Placed Their Heroin Lab Kit Back At ' .. GetCoords(src) .. '!', 'heroin') end end) @@ -166,41 +129,26 @@ end) RegisterServerEvent('md-drugs:server:heatliquidheroin', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'emptyvial', 1, 'true') then return end + if not Itemcheck(source, 'emptyvial', 1) then return end if Config.TierSystem then local cuth = Player.Functions.GetItemByName('heroincut') local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo') local cuth3 = Player.Functions.GetItemByName('heroincutstagethree') if cuth then - RemoveItem('heroincut', 1) - RemoveItem('emptyvial', 1) - AddItem('heroinvial', 1) - Notifys(Lang.Heroin.vial, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Vial Of Heroin', 'heroin') + if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end + Log(GetName(src) ..' Made A Vial Of Heroin', 'heroin') elseif cuth2 then - RemoveItem('heroincutstagetwo', 1) - RemoveItem('emptyvial', 1) - AddItem('heroinvialstagetwo', 1) - Notifys(Lang.Heroin.vial, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Vial Of Heroin Tier 2', 'heroin') + if not GetRecipe(src, 'heroin', 'fillvial', 'tier2') then return end + Log(GetName(src) ..' Made A Vial Of Heroin Tier 2', 'heroin') elseif cuth3 then - RemoveItem('heroincutstagethree', 1) - RemoveItem('emptyvial', 1) - AddItem('heroinvialstagethree', 1) - Notifys(Lang.Heroin.vial, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Vial Of Heroin Tier 3', 'heroin') + if not GetRecipe(src, 'heroin', 'fillvial', 'tier3') then return end + Log(GetName(src) ..' Made A Vial Of Heroin Tier 3', 'heroin') else Notifys(Lang.Heroin.novial, "error") end else - if RemoveItem('heroincut', 1) then - RemoveItem('emptyvial', 1) - AddItem('heroinvial', 1) - Notifys(Lang.Heroin.vial, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Vial Of Heroin', 'heroin') - else - Notifys(Lang.Heroin.novial, "error") - end + if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end + Log(GetName(src) ..' Made A Vial Of Heroin', 'heroin') end end) @@ -210,16 +158,16 @@ local Player = QBCore.Functions.GetPlayer(src) local cuth = Player.Functions.GetItemByName('heroincut') local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo') local cuth3 = Player.Functions.GetItemByName('heroincutstagethree') -Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Sucks And Burned Their Heroin', 'heroin') +Log(GetName(src) ..' Sucks And Burned Their Heroin', 'heroin') if cuth then - RemoveItem('heroincut', 1) - Notifys(Lang.Heroin.fail, "error") + RemoveItem(src, 'heroincut', 1) + Notifys(src,Lang.Heroin.fail, "error") elseif cuth2 then - RemoveItem('heroincutstagetwo', 1) - Notifys(Lang.Heroin.fail, "error") + RemoveItem(src, 'heroincutstagetwo', 1) + Notifys(src,Lang.Heroin.fail, "error") elseif cuth3 then - RemoveItem('heroincutstagethree', 1) - Notifys(Lang.Heroin.fail, "error") + RemoveItem(src, 'heroincutstagethree', 1) + Notifys(src,Lang.Heroin.fail, "error") end end) @@ -227,47 +175,31 @@ end) RegisterServerEvent('md-drugs:server:fillneedle', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.fillneedle[num]['loc']) then return end - if not Itemcheck(Player, 'needle', 1, 'true') then return end + if CheckDist(source, Config.fillneedle[num]['loc']) then return end + if not Itemcheck(src, 'needle', 1) then return end if Config.TierSystem then - local heroin = Player.PlayerData.metadata['heroin'] + local heroin = getRep(src, 'heroin') local vh = Player.Functions.GetItemByName('heroinvial') local vh2 = Player.Functions.GetItemByName('heroinvialstagetwo') local vh3 = Player.Functions.GetItemByName('heroinvialstagethree') if vh then - RemoveItem('heroinvial', 1 ) - RemoveItem('needle', 1) - AddItem('heroin_ready', 1) - Player.Functions.SetMetaData('heroin', (heroin + 1)) - Notifys(Lang.Heroin.fill, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Filled A Needle Of Heroin And Now Has A Rep Of ' .. heroin + 1 .. '!' , 'heroin') + if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end + AddRep(src, 'heroin') + Log(GetName(src) ..' Filled A Needle Of Heroin And Now Has A Rep Of ' .. heroin + 1 .. '!' , 'heroin') elseif vh2 then - RemoveItem('heroinvialstagetwo', 1 ) - RemoveItem('needle', 1) - AddItem('heroin_readystagetwo', 1) - Player.Functions.SetMetaData('heroin', (heroin + 1)) - Notifys(Lang.Heroin.fill, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Filled A Needle Of Heroin Tier 2 And Now Has A Rep Of ' .. heroin + 1 .. '!' , 'heroin') + if not GetRecipe(src, 'heroin', 'fillneedle', 'tier2') then return end + AddRep(src, 'heroin') + Log(GetName(src) ..' Filled A Needle Of Heroin Tier 2 And Now Has A Rep Of ' .. heroin + 1 .. '!' , 'heroin') elseif vh3 then - RemoveItem('heroinvialstagethree', 1 ) - RemoveItem('needle', 1) - AddItem('heroin_readystagethree', 1) - Player.Functions.SetMetaData('heroin', (heroin + 1)) - Notifys(Lang.Heroin.fill, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Filled A Needle Of Heroin Tier 3 And Now Has A Rep Of ' .. heroin + 1 .. '!' , 'heroin') + if not GetRecipe(src, 'heroin', 'fillneedle', 'tier3') then return end + AddRep(src, 'heroin') + Log(GetName(src) ..' Filled A Needle Of Heroin Tier 3 And Now Has A Rep Of ' .. heroin + 1 .. '!' , 'heroin') else - Notifys(Lang.Heroin.nofill, "error") + Notifys(src,Lang.Heroin.nofill, "error") end else - if RemoveItem('heroinvial', 1 ) then - RemoveItem('needle', 1) - AddItem('heroin_ready', 1) - Notifys(Lang.Heroin.fill, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Filled A Needle Of Heroin!' , 'heroin') - else - Notifys(Lang.Heroin.nofill, "error") - end + if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end + Log(GetName(src) ..' Filled A Needle Of Heroin!' , 'heroin') end end) @@ -276,17 +208,17 @@ end) RegisterServerEvent('md-drugs:server:failheroin', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Sucks And Burned Their Heroin', 'heroin') + Log(GetName(src) ..' Sucks And Burned Their Heroin', 'heroin') if Config.TierSystem then local vh = Player.Functions.GetItemByName('heroinvial') local vh2 = Player.Functions.GetItemByName('heroinvialstagetwo') local vh3 = Player.Functions.GetItemByName('heroinvialstagethree') - if vh then RemoveItem('heroinvialstagethree', 1 ) - elseif vh2 then RemoveItem('heroinvialstagetwo', 1) - elseif vh3 then RemoveItem('heroinvial', 1) + if vh then RemoveItem(src, 'heroinvialstagethree', 1 ) + elseif vh2 then RemoveItem(src, 'heroinvialstagetwo', 1) + elseif vh3 then RemoveItem(src, 'heroinvial', 1) end else - RemoveItem('heroinvial', 1) + RemoveItem(src, 'heroinvial', 1) end end) diff --git a/server/lean.lua b/server/lean.lua index 1e237be..81b22d6 100644 --- a/server/lean.lua +++ b/server/lean.lua @@ -2,42 +2,30 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('md-drugs:server:givelean', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) local chance = math.random(1,100) local amount = math.random(1,5) if chance <= 50 then - if AddItem('mdlean', amount) then + if AddItem(src, 'mdlean', amount) then Notifys(Lang.Lean.lean, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. amount .. ' Of Lean' , 'lean') + Log(GetName(src) .. ' Got ' .. amount .. ' Of Lean' , 'lean') end else - if AddItem('mdreddextro', amount) then + if AddItem(src, 'mdreddextro', amount) then Notifys(Lang.Lean.dextro, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. amount .. ' Of Red Dextro' , 'lean') + Log(GetName(src) .. ' Got ' .. amount .. ' Of Red Dextro' , 'lean') end end end) -local lean = {'mdlean', 'mdreddextro'} -for k, v in pairs (lean) do -QBCore.Functions.CreateUseableItem(v, function(source) -local src = source -local Player = QBCore.Functions.GetPlayer(src) - if v == 'mdlean' then - if Player.Functions.GetItemByName('leancup') and Player.Functions.GetItemByName('sprunk') and Player.Functions.GetItemByName('mdlean') then - Player.Functions.RemoveItem('mdlean', 1 ) - Player.Functions.RemoveItem('sprunk', 1 ) - Player.Functions.RemoveItem('leancup', 1 ) - Player.Functions.AddItem('cupoflean', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Cup Of Lean' , 'lean') - end - else - if Player.Functions.GetItemByName('leancup') and Player.Functions.GetItemByName('sprunk') and Player.Functions.GetItemByName('mdreddextro') then - Player.Functions.RemoveItem('mdreddextro', 1 ) - Player.Functions.RemoveItem('sprunk', 1 ) - Player.Functions.RemoveItem('leancup', 1 ) - Player.Functions.AddItem('cupofdextro', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Cup Of Red Dextro' , 'lean') - end + +QBCore.Functions.CreateUseableItem('leancup', function(source, item) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + if Itemcheck(src, 'leancup', 1) then + TriggerClientEvent('md-drugs:client:leancraft', src) end end) -end + +RegisterServerEvent('md-drugs:server:finishcup', function(data) + local src = source + if not GetRecipe(source, 'lean','cups', data.item) then return end +end) \ No newline at end of file diff --git a/server/lsd.lua b/server/lsd.lua index 918c26e..24bdf77 100644 --- a/server/lsd.lua +++ b/server/lsd.lua @@ -1,155 +1,115 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('md-drugs:server:getlysergic', function(num) -local src = source -local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.lysergicacid[num]['loc']) then return end - if AddItem('lysergic_acid', 2) then - Notifys(Lang.lsd.lys, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got Lysergic acid with a distance of ' .. dist(source, playerPed, Config.lysergicacid[num]['loc']) .. '!', 'lsd') + local src = source + if CheckDist(src, Config.lysergicacid[num]['loc']) then return end + if AddItem(src,'lysergic_acid', 2) then + Log(GetName(src) ..' Got Lysergic acid with a distance of ' .. dist(source, Config.lysergicacid[num]['loc']) .. '!', 'lsd') end end) RegisterServerEvent('md-drugs:server:getdiethylamide', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.diethylamide[num]['loc']) then return end - if AddItem('diethylamide', 2) then - Notifys(Lang.lsd.die, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got Diethylamide with a distance of ' .. dist(source, playerPed, Config.diethylamide[num]['loc']) .. '!', 'lsd') + if CheckDist(src, Config.diethylamide[num]['loc']) then return end + if AddItem(src,'diethylamide', 2) then + Log(GetName(src) ..' Got Diethylamide with a distance of ' .. dist(source, Config.diethylamide[num]['loc']) .. '!', 'lsd') end end) QBCore.Functions.CreateUseableItem('lsdlabkit', function(source, item) local src = source -local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(src) if TriggerClientEvent("md-drugs:client:setlsdlabkit", src) then - Player.Functions.RemoveItem("lsdlabkit", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Placed Their LSD Lab Kit Back At ' .. GetEntityCoords(playerPed) .. '!', 'lsd') + RemoveItem(src, "lsdlabkit", 1) + Log(GetName(src) ..' Placed Their LSD Lab Kit Back At ' .. GetCoords(src) .. '!', 'lsd') end -end) +end) -RegisterServerEvent('md-drugs:server:removecleaningkit', function(data) +lib.callback.register('md-drugs:server:removecleaningkit', function(source) local src = source -local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'cleaningkit', 1, 'true') then return end - if RemoveItem("cleaningkit", 1) then - Notifys(Lang.lsd.cleaned, "success") - TriggerClientEvent("md-drugs:client:resetlsdkit", src, data) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wiped Down Their LSD Lab Kit!' , 'lsd') + if not Itemcheck(src, 'cleaningkit', 1) then return end + if RemoveItem(src,"cleaningkit", 1) then + Log(GetName(src) ..' Wiped Down Their LSD Lab Kit!' , 'lsd') + return true end end) RegisterServerEvent('md-drugs:server:getlabkitback', function() local src = source -local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(src) - if AddItem("lsdlabkit", 1) then - Notifys('You Got Your Lab Kit Back', 'success') - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Up Their LSD Lab Kit Back At ' .. GetEntityCoords(playerPed) .. '!', 'lsd') + if AddItem(src,"lsdlabkit", 1) then + Log(GetName(src) ..' Picked Up Their LSD Lab Kit Back At ' .. GetCoords(src) .. '!', 'lsd') end end) RegisterServerEvent('md-drugs:server:heatliquid', function() local src = source -local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'lysergic_acid', 1, 'true') then return end - if not Itemcheck(Player, 'diethylamide', 1, 'true') then return end - RemoveItem('diethylamide', 1) - RemoveItem('lysergic_acid', 1) - AddItem('lsd_one_vial', 1) - Notifys(Lang.lsd.madelsd, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Heated Basic LSD!', 'lsd') - + if not GetRecipe(src, 'lsd', 'vial', 'heat') then return end + Log(GetName(src) ..' Heated Basic LSD!', 'lsd') end) RegisterServerEvent('md-drugs:server:failheating', function() local src = source -local Player = QBCore.Functions.GetPlayer(src) - - RemoveItem('diethylamide', 1) - RemoveItem('lysergic_acid', 1) - Notifys(Lang.lsd.failed, "error") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Failed Basic LSD Like An Idiot!', 'lsd') +if not ChecknRemove(source, {lysergic_acid = 1, diethylamide = 1}) then return end + Notifys(src,Lang.lsd.failed, "error") + Log(GetName(src) ..' Failed Basic LSD Like An Idiot!', 'lsd') end) RegisterServerEvent('md-drugs:server:refinequalityacid', function() local src = source -local Player = QBCore.Functions.GetPlayer(src) local randomchance = math.random(1,100) -if not Itemcheck(Player, 'lsd_one_vial', 1, 'true') then return end +if not Itemcheck(src, 'lsd_one_vial', 1) then return end if Config.TierSystem then - local lsd = Player.PlayerData.metadata['lsd'] - if RemoveItem('lsd_one_vial', 1) then + local lsd = getRep(src, 'lsd') + if RemoveItem(src, 'lsd_one_vial', 1) then if lsd <= 30 then - AddItem('lsd_vial_two', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_two', 1) elseif lsd >= 31 and lsd <= 60 then - AddItem('lsd_vial_three', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_three', 1) elseif lsd >= 61 and lsd <= 90 then - AddItem('lsd_vial_four', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_four', 1) elseif lsd >= 91 and lsd <= 120 then - AddItem('lsd_vial_five', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_five', 1) else - AddItem('lsd_vial_six', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_six', 1) end - Player.Functions.SetMetaData('lsd', (lsd + 1)) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Refined Acid and Now Has A Rep Of ' .. lsd + 1 .. '!', 'lsd') + AddRep(src,'lsd') + Log(GetName(src) ..' Refined Acid and Now Has A Rep Of ' .. lsd + 1 .. '!', 'lsd') end else - if RemoveItem('lsd_one_vial', 1) then + if RemoveItem(src,'lsd_one_vial', 1) then if randomchance <= 60 then - AddItem('lsd_vial_two', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_two', 1) elseif randomchance >= 61 and randomchance <= 75 then - AddItem('lsd_vial_three', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_three', 1) elseif randomchance >= 76 and randomchance <= 85 then - AddItem('lsd_vial_four', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_four', 1) elseif randomchance >= 86 and randomchance <= 93 then - AddItem('lsd_vial_five', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_five', 1) else - AddItem('lsd_vial_six', 1) - Notifys(Lang.lsd.refined, "Success") + AddItem(src,'lsd_vial_six', 1) end - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Refined Acid!', 'lsd') + Log(GetName(src) ..' Refined Acid!', 'lsd') end end end) RegisterServerEvent('md-drugs:server:failrefinequality', function() -local src = source -local Player = QBCore.Functions.GetPlayer(src) -local randomchance = math.random(1,100) -if not Itemcheck(Player, 'lsd_one_vial', 1, 'true') then return end - if RemoveItem('lsd_one_vial', 1) then - Player.Functions.SetMetaData('lsd', (Player.PlayerData.metadata.lsd - 1)) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Failed A Refinement And Now Has A Rep Of ' .. Player.PlayerData.metadata.lsd - 1 .. '!', 'lsd') - if Player.PlayerData.metadata.lsd < 0 then Player.Functions.SetMetaData('lsd', 0) end - end + local src = source + if not Itemcheck(src, 'lsd_one_vial', 1) then return end + RemoveItem('lsd_one_vial', 1) end) RegisterServerEvent('md-drugs:server:gettabpaper', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.gettabs[num]['loc']) then return end + if CheckDist(source, Config.gettabs[num]['loc']) then return end if Player.Functions.RemoveMoney('cash', Config.tabcost * 10) then - AddItem('tab_paper', 10) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bought Tab Paper!', 'lsd') + AddItem(src,'tab_paper', 10) + Log(GetName(src) ..' Bought Tab Paper!', 'lsd') else Notifys(Lang.lsd.broke, "error") end @@ -158,13 +118,12 @@ end) RegisterServerEvent('md-drugs:server:getlabkit', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, vector3(Config.buylsdlabkit.x, Config.buylsdlabkit.y, Config.buylsdlabkit.z)) then return end + if CheckDist(source, vector3(Config.buylsdlabkit.x, Config.buylsdlabkit.y, Config.buylsdlabkit.z)) then return end if Player.Functions.RemoveMoney('cash', Config.lsdlabkitcost) then - AddItem('lsdlabkit', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bought A LSD Lab Kit!', 'lsd') + AddItem(src,'lsdlabkit', 1) + Log(GetName(src) ..' Bought A LSD Lab Kit!', 'lsd') else - Notifys(Lang.lsd.broke, "error") + Notifys(src, Lang.lsd.broke, "error") end end) @@ -174,31 +133,31 @@ end) RegisterServerEvent('md-drugs:server:maketabpaper', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'tab_paper', 1, 'true') then return end - if Player.Functions.RemoveItem('lsd_one_vial', 1) then - RemoveItem('tab_paper', 1) - AddItem('smileyfacesheet', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Smiley Face Sheet', 'lsd') +if not Itemcheck(src,'tab_paper', 1) then return end + if RemoveItem(src,'lsd_one_vial', 1) then + RemoveItem(src,'tab_paper', 1) + AddItem(src,'smileyfacesheet', 1) + Log(GetName(src) ..' Made A Smiley Face Sheet', 'lsd') elseif Player.Functions.RemoveItem('lsd_vial_two', 1) then - RemoveItem('tab_paper', 1) - AddItem('wildcherrysheet', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Wild Cherry Sheet', 'lsd') + RemoveItem(src,'tab_paper', 1) + AddItem(src,'wildcherrysheet', 1) + Log(GetName(src) ..' Made A Wild Cherry Sheet', 'lsd') elseif Player.Functions.RemoveItem('lsd_vial_three', 1) then - RemoveItem('tab_paper', 1) - AddItem('yinyangsheet', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Yin Yang Sheet', 'lsd') + RemoveItem(src,'tab_paper', 1) + AddItem(src,'yinyangsheet', 1) + Log(GetName(src) ..' Made A Yin Yang Sheet', 'lsd') elseif Player.Functions.RemoveItem('lsd_vial_four', 1) then - RemoveItem('tab_paper', 1) - AddItem('pineapplesheet', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Pine Apple Sheet', 'lsd') + RemoveItem(src,'tab_paper', 1) + AddItem(src,'pineapplesheet', 1) + Log(GetName(src) ..' Made A Pine Apple Sheet', 'lsd') elseif Player.Functions.RemoveItem('lsd_vial_five', 1) then - RemoveItem('tab_paper', 1) - AddItem('bartsheet', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Cluckin Bell Sheet', 'lsd') + RemoveItem(src,'tab_paper', 1) + AddItem(src,'bartsheet', 1) + Log(GetName(src) ..' Made A Cluckin Bell Sheet', 'lsd') elseif Player.Functions.RemoveItem('lsd_vial_six', 1) then - RemoveItem('tab_paper', 1) - AddItem('gratefuldeadsheet', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Maze Sheet', 'lsd') + RemoveItem(src,'tab_paper', 1) + AddItem(src,'gratefuldeadsheet', 1) + Log(GetName(src) ..' Made A Maze Sheet', 'lsd') else Notifys(Lang.lsd.novial, "error") end @@ -218,10 +177,9 @@ for k, v in pairs (sheets) do local src = source local Player = QBCore.Functions.GetPlayer(src) local math = math.random(1,10) - if Player.Functions.RemoveItem(v.item, 1) then - Player.Functions.AddItem(v.recieve, math) - TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items[v.recieve], "add", math ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made ' .. math .. 'Tabs of ' .. v.recieve .. '!', 'lsd') + if RemoveItem(src, v.item, 1) then + AddItem(src, v.recieve, math) + Log(GetName(src) ..' Made ' .. math .. 'Tabs of ' .. v.recieve .. '!', 'lsd') end end) end \ No newline at end of file diff --git a/server/mescaline.lua b/server/mescaline.lua index 7427b48..2ecbe49 100644 --- a/server/mescaline.lua +++ b/server/mescaline.lua @@ -21,43 +21,28 @@ function MescalineCooldown(loc) end - -RegisterNetEvent("Mescaline:pickupCane") -AddEventHandler("Mescaline:pickupCane", function(loc) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.Mescaline[loc].location) then end +RegisterNetEvent("Mescaline:pickupCane", function(loc) + if CheckDist(source, Config.Mescaline[loc].location) then return end if not Config.Mescaline[loc].taken then Config.Mescaline[loc].taken = true GlobalState.Mescaline = Config.Mescaline TriggerClientEvent("Mescaline:removeCane", -1, loc) MescalineCooldown(loc) - local Player = QBCore.Functions.GetPlayer(source) - AddItem('cactusbulb', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Cactus Bulbs With a distance of ' .. dist(source, playerPed, Config.Mescaline[loc].location) .. ' vectors', 'mescaline') + AddItem(source,'cactusbulb', 1) + Log(GetName(source) .. ' Picked Cactus Bulbs With a distance of ' .. dist(source, Config.Mescaline[loc].location) .. ' vectors', 'mescaline') end end) - - -RegisterNetEvent("md-drugs:server:drymescaline") -AddEventHandler("md-drugs:server:drymescaline", function() -local src = source -local Player = QBCore.Functions.GetPlayer(src) - - if RemoveItem("cactusbulb", 1) then - AddItem("driedmescaline", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Dried Mescaline', 'mescaline') - else - Notifys(Lang.mescaline.nocactus, "error") - end +RegisterNetEvent("md-drugs:server:drymescaline", function() + local src = source + if not GetRecipe(src, 'mescaline', 'dry', 'dried') then return end + Log(GetName(source) .. ' Dried Mescaline', 'mescaline') end) QBCore.Functions.CreateUseableItem("driedmescaline", function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - - if Player.Functions.RemoveItem("driedmescaline", 1) then + if RemoveItem(src, "driedmescaline", 1) then TriggerClientEvent("md-drugs:client:takemescaline", src) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Consumed Mescaline', 'consume') + Log(GetName(source) .. ' Consumed Mescaline', 'consume') end end) diff --git a/server/meth.lua b/server/meth.lua index ec2f919..d539aef 100644 --- a/server/meth.lua +++ b/server/meth.lua @@ -2,64 +2,46 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('md-drugs:server:startcook', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'ephedrine', 1, 'true') and Itemcheck(Player, 'acetone', 1, 'true') then return end - Notifys("Adding Things To The Mix", "success") - RemoveItem('ephedrine', 1) - RemoveItem('acetone', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Started A Meth Batch', 'Meth') + if not GetRecipe(source, 'meth', 'cook', 'heat') then return end + Notifys(src, "Adding Things To The Mix", "success") + Log(GetName(source) .. ' Started A Meth Batch', 'Meth') end) RegisterServerEvent('md-drugs:server:givemethingridients', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) local chance = math.random(1,100) local amount = math.random(1,5) if chance <= 50 then - if AddItem('ephedrine', amount) then - Notifys(Lang.meth.eph, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. amount .. ' Of Ephedrine', 'Meth') + if AddItem(src,'ephedrine', amount) then + Log(GetName(src) .. ' Got ' .. amount .. ' Of Ephedrine', 'Meth') end else - if AddItem('acetone', amount) then - Notifys(Lang.meth.ace, "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. amount .. ' Of Acetone', 'Meth') + if AddItem(src, 'acetone', amount) then + Log(GetName(src) .. ' Got ' .. amount .. ' Of Acetone', 'Meth') end end end) RegisterServerEvent('md-drugs:server:getmeth', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local amount = math.random(1,5) - - if RemoveItem("empty_weed_bag", amount) then - AddItem("methbags", amount) - Notifys("You Made " .. amount .. " Bags Of Meth!", "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bagged ' .. amount .. 'Of Meth', 'Meth') - else - Notifys(Lang.meth.nobag, "error") - end + local src = source + if not GetRecipe(src, 'meth', 'bag', 'bags') then return end + Log(GetName(src) .. ' Bagged 5 Of Meth', 'Meth') end) RegisterServerEvent('md-drugs:server:geteph', function(num) local src = source - local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.MethEph[num]['loc']) then return end - if AddItem('ephedrine', 1) then - Notifys('Got Ephedrine!', "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. 1 .. 'Of Ephedrine', 'Meth') + if CheckDist(src, Config.MethEph[num]['loc']) then return end + if AddItem(src, 'ephedrine', 1) then + Notifys(src, 'Got Ephedrine!', "success") + Log(GetName(src) .. ' Got ' .. 1 .. 'Of Ephedrine', 'Meth') end end) RegisterServerEvent('md-drugs:server:getace', function(num) local src = source - local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.Methace[num]['loc']) then return end - if AddItem('acetone', 1) then - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. 1 .. 'Of Acetone', 'Meth') - Notifys('Got Acetone!', "success") + if CheckDist(src, Config.Methace[num]['loc']) then return end + if AddItem(src, 'acetone', 1) then + Log(GetName(src) .. ' Got ' .. 1 .. 'Of Acetone', 'Meth') + Notifys(src, 'Got Acetone!', "success") end end) \ No newline at end of file diff --git a/server/oxyruns.lua b/server/oxyruns.lua index c7318be..610067f 100644 --- a/server/oxyruns.lua +++ b/server/oxyruns.lua @@ -1,14 +1,14 @@ QBCore = exports['qb-core']:GetCoreObject() -RegisterServerEvent('md-drugs:server:payfortruck', function() +lib.callback.register('md-drugs:server:payfortruck', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) if Player.Functions.RemoveMoney('cash', Config.TruckPrice ) or Player.Functions.RemoveMoney('bank', Config.TruckPrice ) then - TriggerClientEvent("md-drugs:Client:getoxylocation", src) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Rented A Van For OxyRuns', 'oxy') + Log(GetName(src) .. ' Rented A Van For OxyRuns', 'oxy') + return true else - Notifys(Lang.oxy.broke, "error") + Notifys(src, Lang.oxy.broke, "error") + return false end end) @@ -22,19 +22,19 @@ RegisterServerEvent('md-drugs:server:giveoxybox', function() local item = Config.OxyRandItems[math.random(1, #Config.OxyRandItems)] if chance <= Config.OxyRunDitchChance then - Notifys(Lang.oxy.hot, "error") + Notifys(src, Lang.oxy.hot, "error") Player.Functions.AddMoney("cash", cash * 0.5) if itemchance <= Config.OxyItemChance then - AddItem(item, Config.OxyItemAmount) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. Config.OxyItemAmount .. ' Of ' .. item .. ' For This Drop Off', 'oxy') + AddItem(src, item, Config.OxyItemAmount) + Log(GetName(source) .. ' Got ' .. Config.OxyItemAmount .. ' Of ' .. item .. ' For This Drop Off', 'oxy') end else Notifys(Lang.oxy.next, "success") TriggerClientEvent("md-drugs:client:getoxylocationroute", src) Player.Functions.AddMoney("cash", cash) if itemchance <= Config.OxyItemChance then - AddItem(item, Config.OxyItemAmount) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Got ' .. Config.OxyItemAmount .. ' Of ' .. item .. ' For This Drop Off', 'oxy') + AddItem(src, item, Config.OxyItemAmount) + Log(GetName(source) .. ' Got ' .. Config.OxyItemAmount .. ' Of ' .. item .. ' For This Drop Off', 'oxy') end end diff --git a/server/pharma.lua b/server/pharma.lua index f1c04b8..7b00214 100644 --- a/server/pharma.lua +++ b/server/pharma.lua @@ -1,38 +1,43 @@ local QBCore = exports['qb-core']:GetCoreObject() +local function GetJob(source) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + if Player.PlayerData.job.type == 'ems' then + return true + else + return false + end +end + QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.PlayerData.job.type == 'ems' then + if GetJob(src) then TriggerClientEvent("md-drugs:client:prescriptionpad", src, item) end end) RegisterServerEvent('md-drugs:server:giveprescription', function(item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - Player.Functions.AddItem(item, 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Prescription Of ' .. item .. '!', 'pharma') - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[item], "add", 1) + if GetJob(src) then + AddItem(src, item, 1) + Log(GetName(src) .. ' Made A Prescription Of ' .. item .. '!', 'pharma') + end end) RegisterServerEvent('md-drugs:server:unbottle', function(item) local src = source - local Player = QBCore.Functions.GetPlayer(src) local amount = math.random(10,30) - Player.Functions.AddItem(item, amount) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Unbottled '.. amount .. ' Of ' .. item .. '!', 'pharma') - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[item], "add", amount) + AddItem(src, item, amount) + Log(GetName(src) .. ' Unbottled '.. amount .. ' Of ' .. item .. '!', 'pharma') end) local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'} for m, d in pairs (pharmabottle) do QBCore.Functions.CreateUseableItem(d, function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Player.Functions.RemoveItem(d, 1) then + if RemoveItem(src, d, 1) then TriggerClientEvent("md-drugs:client:unbottle", src, item) - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[d], "remove", 1) end end) end @@ -40,43 +45,40 @@ end local pharmadrugs = { "adderal", "vicodin", "xanax", "morphine"} for k, v in pairs (pharmadrugs) do QBCore.Functions.CreateUseableItem(v, function(source, item) local src = source -local Player = QBCore.Functions.GetPlayer(src) -if TriggerClientEvent('md-drugs:client:takepharma', src, item.name) then - Player.Functions.RemoveItem(item.name, 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Took ' .. item.name .. '!', 'pharma') - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[item.name], "remove", 1) - + if TriggerClientEvent('md-drugs:client:takepharma', src, item.name) then + RemoveItem(src, item.name, 1) + Log(GetName(source) .. ' Took ' .. item.name .. '!', 'pharma') end end) end RegisterServerEvent('md-drugs:server:fillprescription', function() local src = source - local Player = QBCore.Functions.GetPlayer(src) + local Player = QBCore.Functions.GetPlayer(src) local vic = Player.Functions.GetItemByName('vicodin_prescription') local add = Player.Functions.GetItemByName('adderal_prescription') local mor = Player.Functions.GetItemByName('morphine_prescription') local xan = Player.Functions.GetItemByName('xanax_prescription') if vic then - RemoveItem('vicodin_prescription', 1 ) - AddItem('vicodinbottle', 1) - Notifys(Lang.Pharma.pills, "success") + RemoveItem(src,'vicodin_prescription', 1 ) + AddItem(src,'vicodinbottle', 1) + Notifys(src,Lang.Pharma.pills, "success") elseif add then - RemoveItem('adderal_prescription', 1 ) - AddItem('adderalbottle', 1) - Notifys(Lang.Pharma.pills, "success") + RemoveItem(src,'adderal_prescription', 1 ) + AddItem(src,'adderalbottle', 1) + Notifys(src,Lang.Pharma.pills, "success") elseif mor then - RemoveItem('morphine_prescription', 1 ) - AddItem('morphinebottle', 1) - Notifys(Lang.Pharma.pills, "success") + RemoveItem(src,'morphine_prescription', 1 ) + AddItem(src,'morphinebottle', 1) + Notifys(src,Lang.Pharma.pills, "success") elseif xan then - RemoveItem('xanax_prescription', 1 ) - AddItem('xanaxbottle', 1) - Notifys(Lang.Pharma.pills, "success") + RemoveItem(src,'xanax_prescription', 1 ) + AddItem(src,'xanaxbottle', 1) + Notifys(src,Lang.Pharma.pills, "success") else - Notifys(Lang.Pharma.no, "error") + Notifys(src,Lang.Pharma.no, "error") end - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Filled A Prescription!', 'pharma') + Log(GetName(src) .. ' Filled A Prescription!', 'pharma') end) diff --git a/server/recipes.lua b/server/recipes.lua new file mode 100644 index 0000000..c485c2c --- /dev/null +++ b/server/recipes.lua @@ -0,0 +1,169 @@ +local QBCore = exports['qb-core']:GetCoreObject() + +local recipe = { + cocaine = { + cokepowder = { + tier1 = {take = {coca_leaf = 1}, give = {coke = 1}}, + tier2 = {take = {coca_leaf = 1}, give = {cokestagetwo = 1}}, + tier3 = {take = {coca_leaf = 1}, give = {cokestagethree = 1}}, + }, + cutcoke = { + tier1 = {take = {coke = 1, bakingsoda = 1}, give = {loosecoke = 1}}, + tier2 = {take = {cokestagetwo = 1, bakingsoda = 1}, give = {loosecokestagetwo = 1}}, + tier3 = {take = {cokestagethree = 1, bakingsoda = 1}, give = {loosecokestagethree = 1}}, + }, + bagcoke = { + tier1 = {take = {loosecoke = 1, empty_weed_bag = 1}, give = {cokebaggy = 1}}, + tier2 = {take = {loosecokestagetwo = 1, empty_weed_bag = 1}, give = {cokebaggystagetwo = 1}}, + tier3 = {take = {loosecokestagethree = 1, empty_weed_bag = 1}, give = {cokebaggystagethree = 1}}, + } + }, + crack = { + cookcrack = { + tier1 = {take = {loosecoke = 1, bakingsoda = 1}, give = {crackrock = 1}}, + tier2 = {take = {loosecokestagetwo = 1, bakingsoda = 1}, give = {crackrockstagetwo = 1}}, + tier3 = {take = {loosecokestagethree = 1,bakingsoda = 1}, give = {crackrockstagethree = 1}}, + }, + bagcrack = { + tier1 = {take = {crackrock = 1, empty_weed_bag = 1}, give = {baggedcracked = 1}}, + tier2 = {take = {crackrockstagetwo = 1, empty_weed_bag = 1}, give = {baggedcrackedstagetwo = 1}}, + tier3 = {take = {crackrockstagethree = 1, empty_weed_bag = 1}, give = {baggedcrackedstagethree = 1}}, + } + }, + heroin = { + dryheroin = { + tier1 = {take = {poppyresin = 1}, give = {heroin = 1}}, + tier2 = {take = {poppyresin = 1}, give = {heroinstagetwo = 1}}, + tier3 = {take = {poppyresin = 1}, give = {heroinstagethree = 1}}, + }, + cutheroin = { + tier1 = {take = {heroin = 1, bakingsoda = 1}, give = {heroincut = 1}}, + tier2 = {take = {heroinstagetwo = 1, bakingsoda = 1}, give = {heroincutstagetwo = 1}}, + tier3 = {take = {heroinstagethree = 1, bakingsoda = 1}, give = {heroincutstagethree = 1}}, + }, + fillvial = { + tier1 = {take = {heroincut = 1, emptyvial = 1}, give = {heroinvial = 1}}, + tier2 = {take = {heroincutstagetwo = 1, emptyvial = 1}, give = {heroinvialstagetwo = 1}}, + tier3 = {take = {heroincutstagethree = 1, emptyvial = 1}, give = {heroinvialstagethree = 1}}, + }, + fillneedle = { + tier1 = {take = {heroinvial = 1, needle = 1}, give = {heroin_ready = 1}}, + tier2 = {take = {heroin_readystagetwo = 1, needle = 1}, give = {heroin_readystagetwo = 1}}, + tier3 = {take = {heroinvialstagethree = 1, needle = 1}, give = {heroin_readystagethree = 1}}, + } + }, + lsd = { + vial = { + heat = {take = {lysergic_acid = 1, diethylamide = 1,}, give = {lsd_vial_one = 1}} + }, + + }, + mescaline = { + dry = { + dried = {take = {cactusbulb = 1}, give = {driedmescaline = 1} } + } + }, + lean = { + cups = { + cupoflean = {take = {leancup = 1, sprunk = 1, mdlean = 1}, give = {cupoflean = 1}}, + cupofdextro = {take = {leancup = 1, sprunk = 1, mdreddextro = 1}, give = {cupofdextro = 1}}, + } + }, + meth = { + cook = { + heat = {take = {ephedrine = 1, acetone = 1}, give = {}} + }, + bag = { + bags = {take = {empty_weed_bag = 5}, give = {methbags = 5} } + } + }, + weed = { + edibles = { + cannabutter = {take = { mdbutter = 1, grindedweed = 1}, give = {cannabutter = 1}}, + specialbrownie = {take = { cannabutter = 1, flour = 1, chocolate = 1}, give = {specialbrownie = 1}}, + specialcookie = { take = { cannabutter = 1, flour = 1}, give = {specialcookie = 1}}, + specialchocolate = { take = { cannabutter = 1, chocolate = 1}, give = {specialchocolate = 1}}, + specialmuffin = { take = { cannabutter = 1, flour = 1}, give = {specialmuffin = 1}}, + }, + oil = { + shatter = {take = {butane = 1, grindedweed = 1}, give = {'shatter'}} + }, + blunts = { + blunt = {take = {bluntwrap = 1, grindedweed = 1}, give = {blunt = 1}}, + chewyblunt = {take = {bluntwrap = 1, grindedweed = 1, loosecoke = 1}, give = {chewyblunt = 1}}, + leanblunts = {take = {leanbluntwrap = 1, grindedweed = 1}, give = {leanblunts = 1}}, + dextroblunts = {take = {dextrobluntwrap = 1, grindedweed = 1}, give = {dextroblunts = 1}} + }, + bluntwrap = { + leanbluntwrap = {take = {bluntwrap = 5, mdlean = 1}, give = {leanbluntwrap = 5}}, + dextrobluntwrap = {take = {bluntwrap = 5, mdreddextro = 1}, give = {dextrobluntwrap = 5}}, + } + }, + xtc = { + raw = { + raw_xtc = {take = {mdp2p = 1, isosafrole = 1}, give = {raw_xtc = 1}} + }, + singlestack = { + white = {take = {raw_xtc = 1}, give = {white_xtc = 1}}, + red = {take = {raw_xtc = 1, loosecoke = 1 }, give = {red_xtc = 1}}, + orange = {take = {raw_xtc = 1, heroinvial = 1}, give = {orange_xtc = 1}}, + blue = {take = {raw_xtc = 1, crackrock = 1 }, give = {blue_xtc = 1}}, + }, + dualstack = { + white = {take = {raw_xtc = 1}, give = {white_xtc2 = 1}}, + red = {take = {raw_xtc = 1, loosecoke = 1}, give = {red_xtc2 = 1}}, + orange = {take = {raw_xtc = 1, heroinvial = 1}, give = {orange_xtc2 = 1}}, + blue = {take = {raw_xtc = 1, crackrock = 1}, give = {blue_xtc2 = 1}}, + }, + triplestack = { + white = {take = {raw_xtc = 1}, give = {white_xtc3 = 1}}, + red = {take = {raw_xtc = 1, loosecoke = 1}, give = {red_xtc3 = 1}}, + orange = {take = {raw_xtc = 1, heroinvial = 1}, give = {orange_xtc3 = 1}}, + blue = {take = {raw_xtc = 1, crackrock = 1}, give = {blue_xtc3 = 1}}, + }, + quadstack = { + white = {take = {raw_xtc = 1}, give = {white_xtc4 = 1}}, + red = {take = {raw_xtc = 1, loosecoke = 1}, give = {red_xtc4 = 1}}, + orange = {take = {raw_xtc = 1, heroinvial = 1}, give = {orange_xtc4 = 1}}, + blue = {take = {raw_xtc = 1, crackrock = 1}, give = {blue_xtc4 = 1}}, + }, + press = { + dual = {take = {white_xtc = 20, blue_xtc = 20, red_xtc = 20, orange_xtc = 20, singlepress = 1}, give = {dualpress = 1}}, + triple = {take = {white_xtc2 = 50, blue_xtc2 = 50, red_xtc2 = 50, orange_xtc2 = 50, dualpress = 1}, give = {triplepres = 1}}, + quad = { take = {white_xtc3 = 50, blue_xtc3 = 50, red_xtc3 = 50, orange_xtc3 = 50, triplepress = 1}, give = {quadpress = 1}} + } + } +} + +function GetRecipe(source, type, method, tier) + local src = source + local Player = QBCore.Functions.GetPlayer(source) + local has = 0 + local need = 0 + for k, v in pairs (recipe[type][method][tier].take) do + local item = Player.Functions.GetItemByName(k) + if item and item.amount >= v then + has = has + 1 + else + Notifys(src, ' You Need ' .. v .. ' Of ' .. GetLabels(k) .. ' To Do This', 'error') + end + need = need + 1 + end + if has == need then + for k, v in pairs (recipe[type][method][tier].take) do + RemoveItem(src, k, v) + end + for k,v in pairs (recipe[type][method][tier].give) do + AddItem(src, k, v) + end + + return true + else + return false + end + end + +lib.callback.register('md-drugs:server:GetRecipe', function(source, type, cat) +if not source then return false end +return recipe[type][cat] +end) \ No newline at end of file diff --git a/server/shrooms.lua b/server/shrooms.lua index 7cf2e5f..5e4f718 100644 --- a/server/shrooms.lua +++ b/server/shrooms.lua @@ -24,27 +24,23 @@ end RegisterNetEvent("shrooms:pickupCane") AddEventHandler("shrooms:pickupCane", function(loc) local chance = math.random(1,10) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.shrooms[loc].location) then return end + if CheckDist(source, Config.shrooms[loc].location) then return end if not Config.shrooms[loc].taken then Config.shrooms[loc].taken = true GlobalState.shrooms = Config.shrooms TriggerClientEvent("shrooms:removeCane", -1, loc) shroomsCooldown(loc) - local Player = QBCore.Functions.GetPlayer(source) - AddItem('shrooms', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked A Shroom With a distance of ' .. dist(source, playerPed, Config.shrooms[loc].location) .. ' vectors', 'shrooms') + AddItem(source, 'shrooms', 1) + Log(GetName(source) .. ' Picked A Shroom With a distance of ' .. dist(source, Config.shrooms[loc].location) .. ' vectors', 'shrooms') end end) QBCore.Functions.CreateUseableItem('shrooms', function(source, item) local src = source -local Player = QBCore.Functions.GetPlayer(src) - if TriggerClientEvent('md-drugs:client:takeshrooms', src, item.name) then - Player.Functions.RemoveItem('shrooms', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Took Some Mushrooms', 'shrooms') - TriggerClientEvent("QBCore:Notify", src, Lang.Shrooms.trip, 'success') + RemoveItem(src, 'shrooms', 1) + Log(GetName(source) .. ' Took Some Mushrooms', 'shrooms') + Notifys(src, 'You Took Some Shrooms!', 'success') end end) diff --git a/server/travellingmerchant.lua b/server/travellingmerchant.lua index 023954b..0867d9f 100644 --- a/server/travellingmerchant.lua +++ b/server/travellingmerchant.lua @@ -1,13 +1,15 @@ local QBCore = exports['qb-core']:GetCoreObject() - +local loc = math.random(1, #Config.Travellingmerchant) RegisterServerEvent("md-drugs:server:travellingmerchantox", function(amount, money, item, price,table,num) local src = source local Player = QBCore.Functions.GetPlayer(src) - if not table[num]['name'] == item then return end if Player.Functions.RemoveMoney(tostring(money), tonumber(price) * tonumber(amount)) then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add", amount) - Player.Functions.AddItem(item, amount) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bought ' .. amount .. ' Of ' .. item .. ' For ' .. tonumber(price) * tonumber(amount) .. '!', 'merchant') + AddItem(source, item, amount) + Log(GetName(source) .. ' Bought ' .. amount .. ' Of ' .. item .. ' For ' .. tonumber(price) * tonumber(amount) .. '!', 'merchant') end +end) + +lib.callback.register('md-drugs:server:GetMerchant', function(source) +return loc end) \ No newline at end of file diff --git a/server/weed.lua b/server/weed.lua index 5854cd6..6b6840f 100644 --- a/server/weed.lua +++ b/server/weed.lua @@ -22,245 +22,53 @@ end RegisterNetEvent("weed:pickupCane") AddEventHandler("weed:pickupCane", function(loc) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.WeedPlant[loc].location) then return end + local src = source if not Config.WeedPlant[loc].taken then Config.WeedPlant[loc].taken = true GlobalState.WeedPlant = Config.WeedPlant TriggerClientEvent("weed:removeCane", -1, loc) WeedCooldown(loc) - local Player = QBCore.Functions.GetPlayer(source) - AddItem('wetcannabis', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Weed With a distance of ' .. dist(source, playerPed, Config.WeedPlant[loc].location) .. ' vectors', 'weed') + AddItem(src, 'wetcannabis', 1) + Log(GetName(source) .. ' Picked Weed With a distance of ' .. dist(source, Config.WeedPlant[loc].location) .. ' vectors', 'weed') end end) --------------- events + RegisterServerEvent('md-drugs:server:dryoutweed', function() local src = source local Player = QBCore.Functions.GetPlayer(src) - if RemoveItem("wetcannabis", 1) then - AddItem("drycannabis", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Dried Weed', 'weed') + if RemoveItem(src,"wetcannabis", 1) then + AddItem(src,"drycannabis", 1) + Log(GetName(source) .. ' Dried Weed', 'weed') else - Notifys(Lang.Weed.nodry, "error") + Notifys(src, Lang.Weed.nodry, "error") end end) - -RegisterServerEvent('md-drugs:server:makebutter', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'mdbutter', 'grindedweed'} - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - RemoveItem('mdbutter', 1) - RemoveItem('grindedweed', 1) - AddItem('cannabutter', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Canna Butter ', 'weed') - end -end) - - -RegisterServerEvent('md-drugs:server:makebrownies', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'cannabutter', 'flour', 'chocolate' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 3 then - RemoveItem('cannabutter', 1) - RemoveItem('flour', 1) - RemoveItem('chocolate', 1) - AddItem('specialbrownie', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Special Brownies ', 'weed') - end -end) - -RegisterServerEvent('md-drugs:server:makecookies', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'cannabutter', 'flour' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - RemoveItem('cannabutter', 1) - RemoveItem('flour', 1) - AddItem('specialcookie', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Special Cookies ', 'weed') - end -end) - -RegisterServerEvent('md-drugs:server:makechocolate', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'cannabutter', 'chocolate' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - RemoveItem('cannabutter', 1) - RemoveItem('chocolate', 1) - AddItem('specialchocolate', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Special Chocolate ', 'weed') - end -end) - -RegisterServerEvent('md-drugs:server:makemuffin', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'cannabutter', 'flour' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - RemoveItem('cannabutter', 1) - RemoveItem('flour', 1) - AddItem('specialmuffin', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Special Muffin ', 'weed') - end -end) - -RegisterServerEvent('md-drugs:server:makeoil', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'grindedweed', 'butane' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - RemoveItem('butane', 1) - RemoveItem('grindedweed', 1) - AddItem('shatter', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Shatter ', 'weed') - end -end) - - - -RegisterServerEvent('md-drugs:server:rollblunt', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'bluntwrap', 'grindedweed' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - TriggerClientEvent("md-drugs:client:rollanim", src) - RemoveItem('bluntwrap', 1) - RemoveItem('grindedweed', 1) - AddItem('blunt', 1 ) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Rolled A Blunt ', 'weed') - end -end) - -RegisterServerEvent('md-drugs:server:rollleanblunt', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local chance = math.random(1,10) - local recipe = {'bluntwrap', 'mdlean' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - TriggerClientEvent("md-drugs:client:rollanim", src) - RemoveItem("bluntwrap", 1) - AddItem("leanbluntwrap", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Rolled A Lean Blunt ', 'weed') - if chance > 8 then - RemoveItem("mdlean", 1) - end +local bluntwrap = {'mdreddextro','mdlean'} +for k, v in pairs (bluntwrap) do + QBCore.Functions.CreateUseableItem(v, function(source, item) + local src = source + TriggerClientEvent('md-drugs:client:makeBluntWrap', src) + end) end -end) -RegisterServerEvent('md-drugs:server:rolldextroblunt', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local chance = math.random(1,10) - local chance = math.random(1,10) - local recipe = {'mdreddextro', 'mdlean' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 2 then - RemoveItem("bluntwrap", 1) - AddItem("dextrobluntwrap", 1) - TriggerClientEvent("md-drugs:client:rollanim", src) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Rolled A Dextro Blunt ', 'weed') - if chance > 8 then - Player.Functions.RemoveItem("mdreddextro", 1) - end +local bluntwraps = {'leanbluntwrap', 'dextrobluntwrap', 'bluntwrap'} + +for k, v in pairs (bluntwraps) do + QBCore.Functions.CreateUseableItem(v, function(source, item) + local src = source + TriggerClientEvent('md-drugs:client:rollBlunt', source) + end) end -end) -RegisterServerEvent('md-drugs:server:rollchewyblunt', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local recipe = {'bluntwrap', 'loosecoke', 'grindedweed' } - local have = 0 - for k, v in pairs (recipe) do - if Itemcheck(Player, v, 1, 'true') then have = have + 1 end - end - if have == 3 then - RemoveItem("bluntwrap", 1) - RemoveItem("loosecoke", 1) - RemoveItem("grindedweed", 1) - AddItem("chewyblunt", 1) - TriggerClientEvent("md-drugs:client:rollanim", src) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Rolled A Chewy Blunt ', 'weed') - - end -end) ------------------------- usuable items -QBCore.Functions.CreateUseableItem("leanbluntwrap", function(source, item) -local src = source -local Player = QBCore.Functions.GetPlayer(src) -local keef = Player.Functions.GetItemByName("grindedweed") - if keef and keef.amount > 0 then - if Player.Functions.RemoveItem('grindedweed', 1) then - TriggerClientEvent("md-drugs:client:rollanim", src) - Player.Functions.RemoveItem("leanbluntwrap", 1) - Player.Functions.AddItem('leanblunts', 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['leanblunts'], "add", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['grindedweed'], "remove", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['leanbluntwrap'], "remove", 1) - - end - else - Notifys(Lang.Weed.noweed, "error") - end -end) -QBCore.Functions.CreateUseableItem("dextrobluntwrap", function(source, item) -local src = source -local Player = QBCore.Functions.GetPlayer(src) -local keef = Player.Functions.GetItemByName("grindedweed") - - if keef and keef.amount > 0 then - if Player.Functions.RemoveItem('grindedweed', 1) then - TriggerClientEvent("md-drugs:client:rollanim", src) - Player.Functions.RemoveItem("dextrobluntwrap", 1) - Player.Functions.AddItem('dextroblunts', 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['dextroblunts'], "add", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['grindedweed'], "remove", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['dextrobluntwrap'], "remove", 1) - end - else - Notifysu('You Need Keef', 'error', src) - end +RegisterServerEvent('md-drugs:server:MakeWeedItems', function(data) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + if not Player then return end + if not GetRecipe(src, data.recipe, data.table, data.item) then return end end) QBCore.Functions.CreateUseableItem("dabrig", function(source, item) @@ -268,29 +76,20 @@ local src = source local Player = QBCore.Functions.GetPlayer(src) if Player.Functions.GetItemByName("butanetorch") then - if RemoveItemu("shatter", 1, src) then - Notifysu('test', 'success', src) + if RemoveItem(src, "shatter", 1) then + Notifys(src, 'test', 'success') TriggerClientEvent("md-drugs:client:dodabs", src) end end end) -QBCore.Functions.CreateUseableItem("bluntwrap", function(source, item) -local src = source -local Player = QBCore.Functions.GetPlayer(src) -TriggerClientEvent('md-drugs:client:bluntwraps', src) -end) - QBCore.Functions.CreateUseableItem("weedgrinder", function(source, item) local src = source -local Player = QBCore.Functions.GetPlayer(src) - -if Player.Functions.RemoveItem("drycannabis",1 ) then - Player.Functions.AddItem("grindedweed", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["grindedweed"], "add", 1) +if RemoveItem(src, "drycannabis",1 ) then + AddItem(src, "grindedweed", 1) TriggerClientEvent("md-drugs:client:grind", src) else - Notifysu('You Need Dried Weed', 'error', src) + Notifys(src,'You Need Dried Weed', 'error') end end) @@ -299,11 +98,9 @@ local src = source local Player = QBCore.Functions.GetPlayer(src) TriggerClientEvent("md-drugs:client:rollanim", src) Wait(4000) -if Player.Functions.RemoveItem("mdwoods",1 ) then - Player.Functions.AddItem("bluntwrap", 5) - Player.Functions.AddItem("tobacco", 5) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["bluntwrap"], "add", 1) - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["tobacco"], "add", 1) +if RemoveItem(src, "mdwoods",1 ) then + AddItem(src, "bluntwrap", 5) + AddItem(src, "tobacco", 5) end end) diff --git a/server/wholesale.lua b/server/wholesale.lua index e6dc320..ba64a0e 100644 --- a/server/wholesale.lua +++ b/server/wholesale.lua @@ -23,7 +23,7 @@ RegisterServerEvent('md-drugs:server:wholesalecoke', function() local removed = Player.Functions.RemoveItem(v, item.amount) Player.Functions.AddMoney("cash", item.amount * price) Notifys("You received " .. item.amount * price .. " Dollars!" , "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wholesaled Drugs ', 'wholesale') + Log(GetName(source) .. ' Wholesaled Drugs ', 'wholesale') end end end) @@ -47,7 +47,7 @@ RegisterServerEvent('md-drugs:server:wholesalecrack', function() local removed = Player.Functions.RemoveItem(v, item.amount) Player.Functions.AddMoney("cash", item.amount * price) Notifys("You received " .. item.amount * price .. " Dollars!" , "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wholesaled Drugs ', 'wholesale') + Log(GetName(source) .. ' Wholesaled Drugs ', 'wholesale') end end end) @@ -73,7 +73,7 @@ RegisterServerEvent('md-drugs:server:wholesalelsd', function() local removed = Player.Functions.RemoveItem(v, item.amount) Player.Functions.AddMoney("cash", item.amount * price) Notifys("You received " .. item.amount * price .. " Dollars!" , "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wholesaled Drugs ', 'wholesale') + Log(GetName(source) .. ' Wholesaled Drugs ', 'wholesale') end end end) @@ -98,7 +98,7 @@ RegisterServerEvent('md-drugs:server:wholesaleheroin', function() local removed = Player.Functions.RemoveItem(v, item.amount) Player.Functions.AddMoney("cash", item.amount * price) Notifys("You received " .. item.amount * price .. " Dollars!" , "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wholesaled Drugs ', 'wholesale') + Log(GetName(source) .. ' Wholesaled Drugs ', 'wholesale') end end end) @@ -122,7 +122,7 @@ RegisterServerEvent('md-drugs:server:wholesalextc', function() local removed = Player.Functions.RemoveItem(v, item.amount) Player.Functions.AddMoney("cash", item.amount * price) Notifys("You received " .. item.amount * price .. " Dollars!" , "success") - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Wholesaled Drugs ', 'wholesale') + Log(GetName(source) .. ' Wholesaled Drugs ', 'wholesale') end end end) diff --git a/server/xtc.lua b/server/xtc.lua index be1c88f..52431d1 100644 --- a/server/xtc.lua +++ b/server/xtc.lua @@ -3,23 +3,21 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('md-drugs:server:stealisosafrole', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.isosafrole[num]['loc']) then return end - if AddItem("isosafrole", 1) then - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stole isosafrole with a distance of ' .. dist(source, playerPed, Config.isosafrole[num]['loc']) .. ' vectors!', 'xtc') + if CheckDist(source, Config.isosafrole[num]['loc']) then return end + if AddItem(src, "isosafrole", 1) then + Log(GetName(source) .. ' Stole isosafrole with a distance of ' .. dist(source, Config.isosafrole[num]['loc']) .. ' vectors!', 'xtc') end end) RegisterServerEvent('md-drugs:server:stealmdp2p', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.mdp2p[num]['loc']) then return end - if AddItem("mdp2p", 1) then - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stole MDP2P with a distance of ' .. dist(source, playerPed, Config.mdp2p[num]['loc']) .. ' vectors!', 'xtc') - + if CheckDist(source, Config.mdp2p[num]['loc']) then return end + if AddItem(src,"mdp2p", 1) then + Log(GetName(source) .. ' Stole MDP2P with a distance of ' .. dist(source, Config.mdp2p[num]['loc']) .. ' vectors!', 'xtc') end end) + local presses = { {item = 'singlepress', data = 'single'}, {item = 'dualpress', data = 'dual'}, @@ -30,10 +28,9 @@ for k, v in pairs (presses) do QBCore.Functions.CreateUseableItem(v.item, function(source, item) local src = source local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(source) if TriggerClientEvent("md-drugs:client:setpress", src, v.data) then - Player.Functions.RemoveItem(v.item, 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Placed A ' .. v.item .. ' At ' .. GetEntityCoords(playerPed) .. '!', 'xtc') + RemoveItem(src, v.item, 1) + Log(GetName(source) .. ' Placed A ' .. v.item .. ' At ' .. GetCoords(source) .. '!', 'xtc') end end) end @@ -41,23 +38,22 @@ end RegisterServerEvent('md-drugs:server:getpressback', function(type) local src = source local Player = QBCore.Functions.GetPlayer(src) -local playerPed = GetPlayerPed(source) if type == 'single' then - if Player.Functions.GetItemByName('singlepress') then Notifys('You Already Have A Kit') return end - AddItem('singlepress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Their Single Press At ' .. GetEntityCoords(playerPed) .. '!', 'xtc') + if Player.Functions.GetItemByName('singlepress') then Notifys(src, 'You Already Have A Kit') return end + AddItem(src, 'singlepress', 1) + Log(GetName(source) .. ' Picked Their Single Press At ' .. GetCoords(source) .. '!', 'xtc') elseif type == 'dual' then - if Player.Functions.GetItemByName('dualpress') then Notifys('You Already Have A Kit') return end - AddItem('dualpress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Their Dual Press At ' .. GetEntityCoords(playerPed) .. '!', 'xtc') + if Player.Functions.GetItemByName('dualpress') then Notifys(src, 'You Already Have A Kit') return end + AddItem(src, 'dualpress', 1) + Log(GetName(source) .. ' Picked Their Dual Press At ' .. GetCoords(source) .. '!', 'xtc') elseif type == 'triple' then - if Player.Functions.GetItemByName('triplepress') then Notifys('You Already Have A Kit') return end - AddItem('triplepress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Their Triple Press At ' .. GetEntityCoords(playerPed) .. '!', 'xtc') + if Player.Functions.GetItemByName('triplepress') then Notifys(src, 'You Already Have A Kit') return end + AddItem(src, 'triplepress', 1) + Log(GetName(source) .. ' Picked Their Triple Press At ' .. GetCoords(source) .. '!', 'xtc') elseif type == 'quad' then - if Player.Functions.GetItemByName('quadpress') then Notifys('You Already Have A Kit') return end - AddItem('quadpress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Picked Their Quad Press At ' .. GetEntityCoords(playerPed) .. '!', 'xtc') + if Player.Functions.GetItemByName('quadpress') then Notifys(src, 'You Already Have A Kit') return end + AddItem(src, 'quadpress', 1) + Log(GetName(source) .. ' Picked Their Quad Press At ' .. GetCoords(source) .. '!', 'xtc') end end) @@ -65,118 +61,62 @@ end) RegisterServerEvent('md-drugs:server:makextc', function(data) local src = source local Player = QBCore.Functions.GetPlayer(src) - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end + if not Itemcheck(src, 'raw_xtc', 1) then return end if data.data == 'single' then if data.color == 'white' then - if RemoveItem('raw_xtc', 1) then - AddItem('white_xtc', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Single Stack White Pill!', 'xtc') - end + if not GetRecipe(src, 'xtc', 'singlestack', 'white') then return end + Log(GetName(source) .. ' Made A Single Stack White Pill!', 'xtc') elseif data.color == 'red' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'loosecoke', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('loosecoke', 1) - AddItem('red_xtc', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Single Stack Red Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'singlestack', 'red') then return end + Log(GetName(source) .. ' Made A Single Stack Red Pill!', 'xtc') elseif data.color == 'orange' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'heroinvial', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('heroinvial', 1) - AddItem('orange_xtc', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Single Stack Orange Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'singlestack', 'orange') then return end + Log(GetName(source) .. ' Made A Single Stack Orange Pill!', 'xtc') elseif data.color == 'blue' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'crackrock', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('crackrock', 1) - AddItem('blue_xtc', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Single Stack Blue Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'singlestack', 'blue') then return end + Log(GetName(source) .. ' Made A Single Stack Blue Pill!', 'xtc') end elseif data.data == 'dual' then if data.color == 'white' then - if RemoveItem('raw_xtc', 1) then - AddItem('white_xtc2', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Dual Stack White Pill!', 'xtc') - end + if not GetRecipe(src, 'xtc', 'dualstack', 'white') then return end + Log(GetName(source) .. ' Made A Dual Stack White Pill!', 'xtc') elseif data.color == 'red' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'loosecoke', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('loosecoke', 1) - AddItem('red_xtc2', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Dual Stack Red Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'dualstack', 'red') then return end + Log(GetName(source) .. ' Made A Dual Stack Red Pill!', 'xtc') elseif data.color == 'orange' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'heroinvial', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('heroinvial', 1) - AddItem('orange_xtc2', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Dual Stack Orange Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'dualstack', 'orange') then return end + Log(GetName(source) .. ' Made A Dual Stack Orange Pill!', 'xtc') elseif data.color == 'blue' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'crackrock', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('crackrock', 1) - AddItem('blue_xtc2', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Dual Stack Blue Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'dualstack', 'blue') then return end + Log(GetName(source) .. ' Made A Dual Stack Blue Pill!', 'xtc') end elseif data.data == 'triple' then if data.color == 'white' then - if RemoveItem('raw_xtc', 1) then - AddItem('white_xtc3', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Triple Stack White Pill!', 'xtc') - end + if not GetRecipe(src, 'xtc', 'triplestack', 'white') then return end + Log(GetName(source) .. ' Made A Triple Stack White Pill!', 'xtc') elseif data.color == 'red' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'loosecoke', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('loosecoke', 1) - AddItem('red_xtc3', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Triple Stack Red Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'triplestack', 'red') then return end + Log(GetName(source) .. ' Made A Triple Stack Red Pill!', 'xtc') elseif data.color == 'orange' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'heroinvial', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('heroinvial', 1) - AddItem('orange_xtc3', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Triple Stack Orange Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'triplestack', 'orange') then return end + Log(GetName(source) .. ' Made A Triple Stack Orange Pill!', 'xtc') elseif data.color == 'blue' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'crackrock', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('crackrock', 1) - AddItem('blue_xtc3', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Triple Stack Blue Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'triplestack', 'blue') then return end + Log(GetName(source) .. ' Made A Triple Stack Blue Pill!', 'xtc') end elseif data.data == 'quad' then if data.color == 'white' then - if RemoveItem('raw_xtc', 1) then - AddItem('white_xtc4', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Quad Stack White Pill!', 'xtc') - end + if not GetRecipe(src, 'xtc', 'quadstack', 'white') then return end + Log(GetName(source) .. ' Made A Quad Stack White Pill!', 'xtc') elseif data.color == 'red' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'loosecoke', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('loosecoke', 1) - AddItem('red_xtc4', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Quad Stack Red Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'quadstack', 'red') then return end + Log(GetName(source) .. ' Made A Quad Stack Red Pill!', 'xtc') elseif data.color == 'orange' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'heroinvial', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('heroinvial', 1) - AddItem('orange_xtc4', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Quad Stack Orange Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'quadstack', 'orange') then return end + Log(GetName(source) .. ' Made A Quad Stack Orange Pill!', 'xtc') elseif data.color == 'blue' then - if not Itemcheck(Player, 'raw_xtc', 1, 'true') then return end - if not Itemcheck(Player, 'crackrock', 1, 'true') then return end - RemoveItem('raw_xtc', 1) - RemoveItem('crackrock', 1) - AddItem('blue_xtc4', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made A Quad Stack Blue Pill!', 'xtc') + if not GetRecipe(src, 'xtc', 'quadstack', 'blue') then return end + Log(GetName(source) .. ' Made A Quad Stack Blue Pill!', 'xtc') end end end) @@ -186,8 +126,8 @@ RegisterServerEvent('md-drugs:server:buypress', function() local Player = QBCore.Functions.GetPlayer(src) if Player.Functions.RemoveMoney("cash", 20000) then - AddItem("singlepress", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Bought A Pill Press', 'xtc') + AddItem(src, "singlepress", 1) + Log(GetName(source) .. ' Bought A Pill Press', 'xtc') else Notifys(Lang.xtc.cash, "error") end @@ -195,58 +135,19 @@ RegisterServerEvent('md-drugs:server:buypress', function() RegisterServerEvent('md-drugs:server:upgradepress', function(data) local src = source - local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.buypress) then return end + if CheckDist(source, Config.buypress) then return end if data == 'dual' then - local have = 0 - local pill = {'white_xtc', 'blue_xtc', 'red_xtc', 'orange_xtc'} - for k, v in pairs (pill) do - if Itemcheck(Player, v, 20, 'true') then have = have + 1 end - end - if have == 4 then - if not Itemcheck(Player, 'singlepress', 1, 'true') then return end - RemoveItem('white_xtc', 20) - RemoveItem('blue_xtc', 20) - RemoveItem('red_xtc', 20) - RemoveItem('orange_xtc', 20) - RemoveItem('singlepress', 1) - AddItem('dualpress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Upgraded Press To Dual Press', 'xtc') - end + if not GetRecipe(src, 'xtc', 'press', 'dual') then return end + Log(GetName(source) .. ' Upgraded Press To Dual Press', 'xtc') elseif data == 'triple' then - local have = 0 - local pill = {'white_xtc2', 'blue_xtc2', 'red_xtc2', 'orange_xtc2'} - for k, v in pairs (pill) do - if Itemcheck(Player, v, 50, 'true') then have = have + 1 end - end - if have == 4 then - RemoveItem('dualpress', 1) - RemoveItem('white_xtc2', 50) - RemoveItem('blue_xtc2', 50) - RemoveItem('red_xtc2', 50) - RemoveItem('orange_xtc2', 50) - AddItem('triplepress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Upgraded Press To Triple Press', 'xtc') - end + if not GetRecipe(src, 'xtc', 'press', 'triple') then return end + Log(GetName(source) .. ' Upgraded Press To Triple Press', 'xtc') elseif data == 'quad' then - local have = 0 - local pill = {'white_xtc3', 'blue_xtc3', 'red_xtc3', 'orange_xtc3'} - for k, v in pairs (pill) do - if Itemcheck(Player, v, 150, 'true') then have = have + 1 end - end - if have == 4 then - RemoveItem('triplepress', 1) - RemoveItem('white_xtc3', 150) - RemoveItem('blue_xtc3', 150) - RemoveItem('red_xtc3', 150) - RemoveItem('orange_xtc3', 150) - AddItem('quadpress', 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Upgraded Press To Quad Press', 'xtc') - end + if not GetRecipe(src, 'xtc', 'press', 'quad') then return end + Log(GetName(source) .. ' Upgraded Press To Quad Press', 'xtc') else - Notify('huh', 'error') + Notifys(src, 'huh', 'error') end end) @@ -254,13 +155,9 @@ end) RegisterServerEvent('md-drugs:server:makingrawxtc', function(num) local src = source local Player = QBCore.Functions.GetPlayer(src) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.rawxtcloc[num]['loc']) then return end - if not Itemcheck(Player, 'mdp2p', 1, 'true') and not Itemcheck(Player, 'isosafrole', 1, 'true') then return end - RemoveItem('mdp2p', 1) - RemoveItem('isosafrole', 1) - AddItem("raw_xtc", 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Made Raw XTC With A Distance Of ' .. dist(source, playerPed, Config.rawxtcloc[num]['loc']) .. '!', 'xtc') + if CheckDist(source, Config.rawxtcloc[num]['loc']) then return end + if not GetRecipe(src, 'xtc', 'raw', 'raw_xtc') then return end + Log(GetName(source) .. ' Made Raw XTC With A Distance Of ' .. dist(source, Config.rawxtcloc[num]['loc']) .. '!', 'xtc') end) RegisterServerEvent('md-drugs:server:stampwhite', function(num) @@ -274,21 +171,20 @@ RegisterServerEvent('md-drugs:server:stampwhite', function(num) local chance3 = math.random(#one) local four = {'white_playboys4', 'white_aliens4', 'white_pl4', 'white_trolls4', 'white_cats4'} local chance4 = math.random(#one) - local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.stamp[num]['loc']) then return end + if CheckDist(source, Config.stamp[num]['loc']) then return end - if Player.Functions.RemoveItem("white_xtc", 1) then - AddItem(one[chance], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Single White Pill And Got ' .. one[chance] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("white_xtc2", 1) then - AddItem(two[chance2], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Dual White Pill And Got ' .. two[chance2] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("white_xtc3", 1) then - AddItem(three[chance3], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Triple White Pill And Got ' .. three[chance3] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("white_xtc4", 1) then - AddItem(four[chance4], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Quad White Pill And Got ' .. four[chance4] .. '!', 'xtc') + if RemoveItem(src, "white_xtc", 1) then + AddItem(src, one[chance], 1) + Log(GetName(source) .. ' Stamped A Single White Pill And Got ' .. one[chance] .. '!', 'xtc') + elseif RemoveItem(src, "white_xtc2", 1) then + AddItem(src, two[chance2], 1) + Log(GetName(source) .. ' Stamped A Dual White Pill And Got ' .. two[chance2] .. '!', 'xtc') + elseif RemoveItem(src, "white_xtc3", 1) then + AddItem(src, three[chance3], 1) + Log(GetName(source) .. ' Stamped A Triple White Pill And Got ' .. three[chance3] .. '!', 'xtc') + elseif RemoveItem(src, "white_xtc4", 1) then + AddItem(src, four[chance4], 1) + Log(GetName(source) .. ' Stamped A Quad White Pill And Got ' .. four[chance4] .. '!', 'xtc') else Notifys('You Dont Have Unstamped White Pills', 'error') end @@ -306,20 +202,20 @@ RegisterServerEvent('md-drugs:server:stampred', function(num) local four = {'red_playboys4', 'red_aliens4', 'red_pl4', 'red_trolls4', 'red_cats4'} local chance4 = math.random(#one) local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.stamp[num]['loc']) then return end + if CheckDist(source, Config.stamp[num]['loc']) then return end - if Player.Functions.RemoveItem("red_xtc", 1) then - AddItem(one[chance], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Single Red Pill And Got ' .. one[chance] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("red_xtc2", 1) then - AddItem(two[chance2], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Dual Red Pill And Got ' .. two[chance2] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("red_xtc3", 1) then - AddItem(three[chance3], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Triple Red Pill And Got ' .. three[chance3] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("red_xtc4", 1) then - AddItem(four[chance4], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Quad Red Pill And Got ' .. four[chance4] .. '!', 'xtc') + if RemoveItem(src, "red_xtc", 1) then + AddItem(src, one[chance], 1) + Log(GetName(source) .. ' Stamped A Single Red Pill And Got ' .. one[chance] .. '!', 'xtc') + elseif RemoveItem(src, "red_xtc2", 1) then + AddItem(src, two[chance2], 1) + Log(GetName(source) .. ' Stamped A Dual Red Pill And Got ' .. two[chance2] .. '!', 'xtc') + elseif RemoveItem(src, "red_xtc3", 1) then + AddItem(src, three[chance3], 1) + Log(GetName(source) .. ' Stamped A Triple Red Pill And Got ' .. three[chance3] .. '!', 'xtc') + elseif RemoveItem(src, "red_xtc4", 1) then + AddItem(src, four[chance4], 1) + Log(GetName(source) .. ' Stamped A Quad Red Pill And Got ' .. four[chance4] .. '!', 'xtc') else Notifys('You Dont Have Unstamped red Pills', 'error') end @@ -337,20 +233,20 @@ RegisterServerEvent('md-drugs:server:stamporange', function(num) local four = {'orange_playboys4', 'orange_aliens4', 'orange_pl4', 'orange_trolls4', 'orange_cats4'} local chance4 = math.random(#one) local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.stamp[num]['loc']) then return end + if CheckDist(source, Config.stamp[num]['loc']) then return end - if Player.Functions.RemoveItem("orange_xtc", 1) then - AddItem(one[chance], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Single Orange Pill And Got ' .. one[chance] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("orange_xtc2", 1) then - AddItem(two[chance2], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Dual Orange Pill And Got ' .. two[chance2] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("orange_xtc3", 1) then - AddItem(three[chance3], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Triple Orange Pill And Got ' .. three[chance3] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("orange_xtc4", 1) then - AddItem(four[chance4], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Quad Orange Pill And Got ' .. four[chance4] .. '!', 'xtc') + if RemoveItem(src, "orange_xtc", 1) then + AddItem(src, one[chance], 1) + Log(GetName(source) .. ' Stamped A Single Orange Pill And Got ' .. one[chance] .. '!', 'xtc') + elseif RemoveItem(src, "orange_xtc2", 1) then + AddItem(src, two[chance2], 1) + Log(GetName(source) .. ' Stamped A Dual Orange Pill And Got ' .. two[chance2] .. '!', 'xtc') + elseif RemoveItem(src, "orange_xtc3", 1) then + AddItem(src, three[chance3], 1) + Log(GetName(source) .. ' Stamped A Triple Orange Pill And Got ' .. three[chance3] .. '!', 'xtc') + elseif RemoveItem(src, "orange_xtc4", 1) then + AddItem(src, four[chance4], 1) + Log(GetName(source) .. ' Stamped A Quad Orange Pill And Got ' .. four[chance4] .. '!', 'xtc') else Notifys('You Dont Have Unstamped orange Pills', 'error') end @@ -368,19 +264,19 @@ RegisterServerEvent('md-drugs:server:stampblue', function(num) local four = {'blue_playboys4', 'blue_aliens4', 'blue_pl4', 'blue_trolls4', 'blue_cats4'} local chance4 = math.random(#one) local playerPed = GetPlayerPed(source) - if CheckDist(source, playerPed, Config.stamp[num]['loc']) then return end - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Single Blue Pill And Got ' .. one[chance] .. '!', 'xtc') - if Player.Functions.RemoveItem("blue_xtc", 1) then - AddItem(one[chance], 1) - elseif Player.Functions.RemoveItem("blue_xtc2", 1) then - AddItem(two[chance2], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Dual Blue Pill And Got ' .. two[chance2] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("blue_xtc3", 1) then - AddItem(three[chance3], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Triple Blue Pill And Got ' .. three[chance3] .. '!', 'xtc') - elseif Player.Functions.RemoveItem("blue_xtc4", 1) then - AddItem(four[chance4], 1) - Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Stamped A Quad Blue Pill And Got ' .. four[chance4] .. '!', 'xtc') + if CheckDist(source, Config.stamp[num]['loc']) then return end + Log(GetName(source) .. ' Stamped A Single Blue Pill And Got ' .. one[chance] .. '!', 'xtc') + if RemoveItem(src, "blue_xtc", 1) then + AddItem(src, one[chance], 1) + elseif RemoveItem(src, "blue_xtc2", 1) then + AddItem(src, two[chance2], 1) + Log(GetName(source) .. ' Stamped A Dual Blue Pill And Got ' .. two[chance2] .. '!', 'xtc') + elseif RemoveItem(src, "blue_xtc3", 1) then + AddItem(src, three[chance3], 1) + Log(GetName(source) .. ' Stamped A Triple Blue Pill And Got ' .. three[chance3] .. '!', 'xtc') + elseif RemoveItem(src, "blue_xtc4", 1) then + AddItem(src, four[chance4], 1) + Log(GetName(source) .. ' Stamped A Quad Blue Pill And Got ' .. four[chance4] .. '!', 'xtc') else Notifys('You Dont Have Unstamped blue Pills', 'error') end diff --git a/shared/config.lua b/shared/config.lua index b59a201..a52d539 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -1,6 +1,6 @@ Config = {} --Ignore. -Config.oxtarget = false --- turn to true if you use oxtarget +Config.Target = 'qb' -- qb or ox Config.respawnTime = 150 -- Seconds 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) @@ -13,14 +13,30 @@ Config.Tier2 = 300 -- amount to hit for level 3 ---------------------------------- BRIDGE Config.progressbartype = 'oxcir' -- either 'qb', 'oxcir', 'oxbar' -Config.minigametype = 'ox' -- either 'ps' or 'ox' or 'none' Config.Notify = 'ox' -- -- either 'qb' or 'ox' or 'okok' Config.Phone = 'qb' -- either 'qb' or 'yflip' or 'qs' Config.Dispatch = 'ps' -- either 'ps', 'cd', 'core', 'aty' +Config.Minigames = { + ps = { amount = 2, speed = 8,}, + ox = { 'easy', 'easy'}, --easy medium or hard each one corresponds to how many skillchecks and the difficulty + blcirprog = { amount = 2, speed = 50}, -- speed = 1-100 + blprog = { amount = 1, speed = 50}, -- speed = 1-100 + blkeyspam = { amount = 1, difficulty = 50}, -- difficulty = 1-100 + blkeycircle = { amount = 1, difficulty = 50, keynumbers = 3}, + blnumberslide = { amount = 1, difficulty = 50, keynumbers = 3}, + blrapidlines = { amount = 1, difficulty = 50, numberofline = 3}, + blcircleshake = { amount = 1, difficulty = 50, stages = 3}, + glpath = { gridsize = 10, lives = 3, timelimit = 999999}, + glspot = {gridSize = 6, timeLimit = 999999, charSet = "alphabet", required = 10}, + glmath = {timeLimit = 300000}, + +} +Config.minigametype = 'blkeyspam' -- look above for options or choose none if you dont want any minigames + ------------- you can either set a gang or leave it blank, if blank it will autopopulate data to not require it :) ------------- Cocaine -- new animations require to be in a certain spot or they get fucky. uses bob74 ipl if you turn Config.FancyCokeAnims you can put it anywhere :) -Config.FancyCokeAnims = false -- if you want multi location this needs to be false +Config.FancyCokeAnims = true -- if you want multi location this needs to be false Config.CokeTeleIn = vector3(198.16, -1276.92, 29.33)-- where you target to go inside @@ -28,12 +44,14 @@ Config.CokeTeleOut = vector3(1088.81, -3187.57, -38.99) -- where you target to l Config.MakePowder = { -- where you chop your coca leaves to make powder {loc = vector3(1086.20, -3195.30, -39.20), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, + {loc = vector3(1090.15, -3199.5, -39.18), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, + {loc = vector3(1093.09, -3199.53, -39.05), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, } Config.CuttingCoke = { -- only active if Config.FancyCokeAnims = false - {loc = vector3(1095.66, -3195.4, -39.13), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, + {loc = vector3(1095.61, -3195.62, -39.13), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, } Config.BaggingCoke = { -- only active if Config.FancyCokeAnims = false - {loc = vector3(1100.34, -3199.44, -39.19), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, + {loc = vector3(1100.3, -3199.42, -39.19), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, } ---------------- Crack locations Config.makecrack = { -- make crack with baking soda with cut coke 1-3 @@ -99,7 +117,7 @@ Config.stamp = { -- where to stamp pills Config.buypress = vector3(845.82, -884.79, 25.18)-- Where you buy your presses ----- mescaline -Config.DryOut = vector3(2622.6, 4222.57, 43.6) -- Place to dry out mescaline into usuable drug +Config.DryOut = vector3(2638.22, 4237.93, 44.78) -- Place to dry out mescaline into usuable drug Config.Badtrip = 20 -- number means % chance to spawn a clone that chases and attacks while on mescaline @@ -126,14 +144,14 @@ Config.PharmaJob = "ems" -- what TYPE role you need to be on to get the command Config.Teleout = vector3(1066.31, -3183.36, -39.16) -- where you target to tele in Config.Telein = vector3(244.74, 374.54, 105.74) -- where you target to tele out Config.MakeButter = vector3(1045.48, -3198.49, -38.22) -- where you make cannabutter and baked edibles -Config.MakeOil = vector3(1038.90, -3198.66, -38.17-1) -- where you make shatter +Config.MakeOil = vector3(1038.90, -3198.66, -38.17) -- where you make shatter Config.WeedSaleman = vector4(1030.46, -3203.63, -38.2, 180.0) Config.WeedDry = { -- where you dry leaves - vector3(1043.0, -3191.59, -38.39), - vector3(1041.0, -3191.59, -38.39), - vector3(1045.0, -3191.59, -38.39), - vector3(1039.0, -3191.59, -38.39), + {loc = vector3(1043.0, -3191.59, -38.39),}, + {loc = vector3(1041.0, -3191.59, -38.39),}, + {loc = vector3(1045.0, -3191.59, -38.39),}, + {loc = vector3(1039.0, -3191.59, -38.39),}, } Config.Joblock = false -- if you want weed to be a job @@ -157,7 +175,7 @@ Config.Weed = { --- this is the store for the weed ingridients Config.SuccessfulChance = 90 --- this is the chance of a Success wholesale 1-100 Config.AlertPoliceWholesale = 90 -- 1-100 of how often it will alert police Config.WholesaleTimeout = 600 -- time in seconds to get to the location -Config.PoliceCount = 2 -- Amount of police required +Config.PoliceCount = 0 -- Amount of police required Config.Wcoke = { min = 20, max = 60} -- pricings per item Config.Wcrack = { min = 20, max = 60} Config.Wlsd = { min = 20, max = 60} @@ -173,30 +191,30 @@ Config.Travellingmerchant = { ------------ these are the random locations the me } Config.Items = { --- this is the store for the travelling merchant items = { - [1] = {name = "tab_paper", price = 50, amount = 50, }, - [2] = {name = "bakingsoda", price = 25, amount = 50, }, - [3] = {name = "isosafrole", price = 25, amount = 50, }, - [4] = {name = "mdp2p", price = 25, amount = 50, }, - [5] = {name = "lysergic_acid", price = 25, amount = 50, }, - [6] = {name = "diethylamide", price = 25, amount = 50, }, - [7] = {name = "lockpick", price = 2, amount = 1000, }, - [8] = {name = "emptyvial", price = 2, amount = 1000, }, - [9] = {name = "needle", price = 2, amount = 1000, }, - [10] = {name = "cokeburner", price = 25, amount = 50, }, - [11] = {name = "crackburner", price = 2, amount = 50, }, - [12] = {name = "lsdburner", price = 2, amount = 50, }, - [13] = {name = "heroinburner", price = 2, amount = 50, }, - [14] = {name = "mdlean", price = 50, amount = 50, }, - [15] = {name = "weedgrinder", price = 25, amount = 50, }, - [16] = {name = "mdbutter", price = 25, amount = 50, }, - [17] = {name = "flour", price = 25, amount = 50, }, - [18] = {name = "chocolate", price = 25, amount = 50, }, - [19] = {name = "butane", price = 25, amount = 50, }, - [20] = {name = "butanetorch", price = 2, amount = 1000, }, - [21] = {name = "dabrig", price = 2, amount = 1000, }, - [22] = {name = "mdwoods", price = 2, amount = 1000, }, - [23] = {name = "leancup", price = 25, amount = 50, }, - [24] = {name = "xtcburner", price = 25, amount = 50, }, + {name = "tab_paper", price = 50, amount = 50,}, + {name = "bakingsoda", price = 25, amount = 50, }, + {name = "isosafrole", price = 25, amount = 50, }, + {name = "mdp2p", price = 25, amount = 50, }, + {name = "lysergic_acid", price = 25, amount = 50, }, + {name = "diethylamide", price = 25, amount = 50, }, + {name = "lockpick", price = 2, amount = 1000, }, + {name = "emptyvial", price = 2, amount = 1000, }, + {name = "needle", price = 2, amount = 1000, }, + {name = "cokeburner", price = 25, amount = 50, }, + {name = "crackburner", price = 2, amount = 50, }, + {name = "lsdburner", price = 2, amount = 50, }, + {name = "heroinburner", price = 2, amount = 50, }, + {name = "mdlean", price = 50, amount = 50, }, + {name = "weedgrinder", price = 25, amount = 50, }, + {name = "mdbutter", price = 25, amount = 50, }, + {name = "flour", price = 25, amount = 50, }, + {name = "chocolate", price = 25, amount = 50, }, + {name = "butane", price = 25, amount = 50, }, + {name = "butanetorch", price = 2, amount = 1000, }, + {name = "dabrig", price = 2, amount = 1000, }, + {name = "mdwoods", price = 2, amount = 1000, }, + {name = "leancup", price = 25, amount = 50, }, + {name = "xtcburner", price = 25, amount = 50, }, } } @@ -205,7 +223,7 @@ Config.Items = { --- this is the store for the travelling merchant ----- when you get to the drop off point third eye the truck. You will carry a box to the ped. He will give you cash, some oxy and maybe a random item. Rinse and repeat -Config.truckspawn = vector4(1449.65, -1486.0, 63.22, 342.58) --- where the truck will spawn when you pay for it +Config.truckspawn = vector4(1450.87, -1482.13, 63.22, 69.95) --- where the truck will spawn when you pay for it Config.Payfortruck = vector3(1437.64, -1491.91, 63.62) --- where you pay for the truck Config.TruckPrice = 500 -- amount the truck will cost to rent Config.OxyRunCompleteCash = 200 -- base price you get for completeing a run. 50% if the car needs to be ditched diff --git a/shared/qbdrugsrewrite.lua b/shared/qbdrugsrewrite.lua index da0341b..aace4f3 100644 --- a/shared/qbdrugsrewrite.lua +++ b/shared/qbdrugsrewrite.lua @@ -4,7 +4,7 @@ QBConfig = {} ------------ and changed the range a ped will walk up to you to be a bigger radius. QBConfig.MinimumDrugSalePolice = 0 -QBConfig.MarkedBills = false -- if false on both options below then it auto converts selling to give cash +QBConfig.MarkedBills = true -- if false on both options below then it auto converts selling to give cash QBConfig.CustomDirtyMoney = false QBConfig.CustomDirtyMoneyitem = '' @@ -140,9 +140,6 @@ QBConfig.DrugsPrice = { ["cupofdextro"] = {min = 18, max = 40}, } - Debug = false -- true / false - Currently prints the vector3 and label of locations when requesting a delivery - NearbyDeliveries = false -- true / false - Do you want deliveries to be within a certain amount of units? - DeliveryWithin = 2000 -- int (Default 2000) - How many units do you want the delivery location to be within from the player when making a delivery request? QBConfig.Dealers = {} @@ -171,8 +168,8 @@ QBConfig.WrongAmountFee = 2 -- divide the payout by this value for wrong deliver QBConfig.OverdueDeliveryFee = 4 -- divide the payout by this value for overdue delivery QBConfig.DeliveryItems = { - [1] = { ["item"] = "weed_brick", ["minrep"] = 0, ['payout'] = 1000}, - [2] = { ["item"] = "coke_brick", ["minrep"] = 0, ['payout'] = 1000}, + { item = "weed_brick", minrep = 0, payout = {min = 10, max = 50}}, + { item = "coke_brick", minrep = 0, payout = {min = 10, max = 50}}, } QBConfig.DeliveryLocations = { diff --git a/test.sql b/test.sql new file mode 100644 index 0000000..4e801d6 --- /dev/null +++ b/test.sql @@ -0,0 +1,19 @@ + +CREATE TABLE IF NOT EXISTS `deliveriesdealer` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cid` varchar(50) NOT NULL, + `itemdata` varchar(50) NOT NULL, + `timestart` varchar(50) NOT NULL, + `timestop` varchar(50) DEFAULT NULL, + `maxtime` varchar(50) NOT NULL, + `location` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; + +CREATE TABLE IF NOT EXISTS `drugrep` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cid` varchar(50) DEFAULT NULL, + `drugrep` varchar(255) DEFAULT NULL, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; diff --git a/version.txt b/version.txt index 04dbb32..e17f512 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -3.5.9 +3.7.0