- fix up heroin

This commit is contained in:
Mustache Dom committed 2025-07-14 01:34:58 -07:00
1 parent 1b29aaa3b0
commit 4fdef3cf30
8 files changed
+795 -476

No files matched your search

+21 -20
View File
@@ -1,27 +1,32 @@
local CocaPlant = {} local CocaPlant = {}
local cuttingcoke = nil local cuttingcoke = nil
local baggingcoke = nil local baggingcoke = nil
local function pick(loc) local function pick(loc)
if not progressbar(Lang.Coke.picking, 4000, 'uncuff') then return end if not progressbar(Lang.Coke.picking, 4000, 'uncuff') then return end
TriggerServerEvent("coke:pickupCane", loc) TriggerServerEvent("coke:pickupCane", loc)
return true return true
end end
local function targetOps(loc)
return {
{
icon = "fa-solid fa-seedling",
label = ps.lang('targets.coke.pick'),
action = function()
if not pick(loc) then return end
end
}
}
end
RegisterNetEvent('coke:respawnCane', function(loc) RegisterNetEvent('coke:respawnCane', function(loc)
local v = GlobalState.CocaPlant[loc] local v = GlobalState.CocaPlant[loc]
local hash = GetHashKey(v.model) local hash = GetHashKey(v.model)
if not CocaPlant[loc] then if not CocaPlant[loc] then
CocaPlant[loc] = CreateObject(hash, v.location, false, true, true) CocaPlant[loc] = CreateObject(hash, v.location, false, true, true)
Freeze(CocaPlant[loc], true, v.heading) Freeze(CocaPlant[loc], true, v.heading)
ps.entityTarget(CocaPlant[loc], { ps.entityTarget(CocaPlant[loc], targetOps(loc))
{
icon = "fa-solid fa-seedling",
label = ps.lang('targets.coke.pick'),
action = function()
if not pick(loc) then return end
end
}
})
end end
end) end)
@@ -37,15 +42,7 @@ RegisterNetEvent("coke:init", function()
if not v.taken then if not v.taken then
CocaPlant[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true) CocaPlant[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true)
Freeze(CocaPlant[k], true, v.heading) Freeze(CocaPlant[k], true, v.heading)
ps.entityTarget(CocaPlant[k], { ps.entityTarget(CocaPlant[k], targetOps(k))
{
icon = "fa-solid fa-seedling",
label = ps.lang('targets.coke.pick'),
action = function()
if not pick(k) then return end
end
}
})
end end
end end
end) end)
@@ -67,7 +64,10 @@ for k, v in pairs (GlobalState.MDDrugsLocs.MakePowder) do
label = ps.lang('.targets.coke.pick'), label = ps.lang('.targets.coke.pick'),
icon = 'fa-solid fa-seedling', icon = 'fa-solid fa-seedling',
action = function() action = function()
if not ps.hasItem('coca_leaf') then return end if not ps.hasItem('coca_leaf') then
ps.notify('You Need A Coke Leaf')
return
end
if not ps.progressbar(ps.lang('Coke.makepow'), 4000, 'uncuff') then return end if not ps.progressbar(ps.lang('Coke.makepow'), 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:makepowder", k) TriggerServerEvent("md-drugs:server:makepowder", k)
end, end,
@@ -94,6 +94,7 @@ for k, v in pairs (GlobalState.MDDrugsLocs.CuttingCoke) do
} }
}) })
end end
for k, v in pairs (GlobalState.MDDrugsLocs.BaggingCoke) do for k, v in pairs (GlobalState.MDDrugsLocs.BaggingCoke) do
ps.boxTarget('bagcoke'..k, v.loc, {length = 1.0, width = 1.0, height = 1.0, rotation = 180.0}, { ps.boxTarget('bagcoke'..k, v.loc, {length = 1.0, width = 1.0, height = 1.0, rotation = 180.0}, {
{ {
@@ -109,4 +110,4 @@ for k, v in pairs (GlobalState.MDDrugsLocs.BaggingCoke) do
end end
} }
}) })
end end
+148 -90
View File
@@ -1,115 +1,173 @@
local sell = false local sell = false
local sold = false
local targbusy = false
local inZone = false local inZone = false
local active = false local buyers = {}
local function reset(targ) local function walkAway(targ)
FreezeEntityPosition(targ, false) FreezeEntityPosition(targ, false)
ClearPedTasks(targ) ClearPedTasks(targ)
local coords = GetEntityCoords(targ)
TaskWanderInArea(targ, coords.x, coords.y, coords.z, 100.0, 2, 10.0)
Wait(10000)
DeletePed(targ)
targbusy = false
sold = true
active = false
end
local function walkAway(targ)
FreezeEntityPosition(targ, false)
ClearPedTasks(targ)
local coords = GetEntityCoords(targ)
TaskWanderInArea(targ, coords.x, coords.y, coords.z, 100.0, 2, 10.0)
Wait(10000)
DeletePed(targ)
targbusy = false
active = false
end end
local function sellDrug(item, amount, price, targ) local function sellDrug(item, amount, price, targ)
PoliceCall(20) -- PoliceCall(20)
targbusy = true if ps.vehicleData() then
if IsPedInAnyVehicle(PlayerPedId(), true) then Notify(ps.lang('Cornerselling.inveh', 'error'))
Notify(Lang.Cornerselling.inveh, 'error') walkAway(targ)
reset(targ) return
return end end
if not progressbar(string.format(Lang.Cornerselling.selling, GetLabel(item), price), 4000, 'uncuff') then return end
if not ps.progressbar(string.format(ps.lang('Cornerselling.selling', GetLabel(item), price)), 4000, 'uncuff') then walkAway(targ) return end
buyers[targ] = 'sold'
TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, amount, price) TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, amount, price)
reset(targ) walkAway(targ)
end end
local function deny(targ) local function deny(targ)
PoliceCall(20) -- PoliceCall(20)
targbusy = true buyers[targ] = 'sold'
if not progressbar(Lang.Cornerselling.deny, 4000, 'argue5') then return end if not ps.progressbar(ps.lang('Cornerselling.deny'), 4000, 'argue5') then return end
reset(targ) walkAway(targ)
end
local function findPed()
local targ = nil
repeat
Wait(100)
targ = ps.getNearestPed(GetEntityCoords(PlayerPedId()), 8)
if IsPedInAnyVehicle(targ, false) or GetEntityHealth(targ) == 0 or not IsPedHuman(targ) then
targ = nil
end
if buyers[targ] then
targ = nil
end
if inZone then
targ = nil
end
until targ ~= nil
buyers[targ] = true
ps.drawText('Waiting For Customer')
repeat
Wait(1000)
TaskGoToCoordAnyMeans(targ, GetEntityCoords(PlayerPedId()), 1.0, 0, 0, 0, 0)
until #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(targ)) < 2.0
TaskTurnPedToFaceEntity(targ, PlayerPedId(), -1)
ps.hideText()
CreateThread(function()
Wait(45000)
walkAway(targ)
buyers[targ] = 'sold'
end)
return targ
end
local function checkItems()
local count = 0
for k, v in pairs (GlobalState.DrugNames) do
if ps.hasItem(v) then
count = count + 1
break
end
end
if count == 0 then ps.notify(ps.lang('Cornerselling.nodrugs', 'error')) return false end
return true
end end
function Cornersell() function Cornersell()
if active then return false end if inZone then sell = false return end
local targ = lib.GetClosestPed(GetEntityCoords(PlayerPedId()), 8)
if targ == nil then return end if not sell then
if IsPedInAnyVehicle(targ, false) or GetEntityHealth(targ) == 0 or not IsPedHuman(targ) then return end return
local data = ps.callback('md-drugs:server:cornerselling:getAvailableDrugs', false, targ) end
if data.item == 'nothing' then Notify(Lang.Cornerselling.nodrugs, 'error') sell = false FreezeEntityPosition(targ, false) ClearPedTasks(targ) active = false return false end
TaskGoToCoordAnyMeans(targ, GetEntityCoords(PlayerPedId()), 1.0, 0, 0, 0, 0) local hasDrugs = checkItems()
active = true if not hasDrugs then
repeat sell = false
Wait(1000) return
until #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(targ)) < 2.0 end
lib.requestAnimDict("rcmme_tracey1")
TaskStartScenarioInPlace(targ, "WORLD_HUMAN_STAND_IMPATIENT_UPRIGHT", 0, false) FreezeEntityPosition(targ, true) ps.drawText('Searching For Nearby Customers')
AddMultiModel(data.ped, {
{ label = string.format(Lang.targets.CornerSell.sell, data.amount, GetLabel(data.item), data.price), icon ="fa-solid fa-money-bill", local targ = findPed()
action = function() sellDrug(data.item, data.amount, data.price, targ) end, local data = ps.callback('md-drugs:server:cornerselling:getAvailableDrugs', targ)
canInteract = function()
if not targbusy then return true end end, if data == false then
}, sell = false
{ label = Lang.targets.CornerSell.deny, icon = "fa-solid fa-person-harassing", return
action = function() deny(targ) end, end
canInteract = function()
if not targbusy then return true end end, if data == 'robbed' then
TaskGoStraightToCoord(targ, -1858.232910, -1242.395630, 8.60510, 100.0, -1, 0.0, 0.0)
SetPedMoveRateOverride(targ, 10.0)
local got = false
ps.entityTarget(targ, {
{
label = "Take Back Drugs",
icon ="fa-solid fa-money-bill",
action = function()
got = true
TriggerServerEvent('md-drugs:server:getBackRobbed')
Cornersell()
end,
canInteract = function()
if IsEntityDead(targ) and not got then
return true
end
end,
}}, nil) }}, nil)
local timer = 45 else
repeat ps.requestAnim("rcmme_tracey1")
Wait(1000) TaskStartScenarioInPlace(targ, "WORLD_HUMAN_STAND_IMPATIENT_UPRIGHT", 0, false)
timer = timer - 1 FreezeEntityPosition(targ, true)
until sold or timer == 0 ps.entityTarget(data.ped, {
if sold then sold = false return true end {
if timer == 0 then Notify(Lang.Cornerselling.timeout, 'error') targbusy = true walkAway(targ) return false end label = string.format(ps.lang('targets.CornerSell.sell', data.amount, GetLabel(data.item), data.price)),
icon ="fa-solid fa-money-bill",
action = function()
sellDrug(data.item, data.amount, data.price, targ)
Cornersell()
end,
canInteract = function()
if buyers[targ] ~= 'sold' and sell then
return true
end
end,
},
{
label = ps.lang('targets.CornerSell.deny'),
icon = "fa-solid fa-person-harassing",
action = function()
deny(targ)
walkAway(targ)
Cornersell()
end,
canInteract = function()
if buyers[targ] == true and sell then
return true
end
end
}
})
end
end end
RegisterNetEvent('md-drugs:client:cornerselling', function() RegisterNetEvent('md-drugs:client:cornerselling', function()
if not GetCops(QBConfig.MinimumDrugSalePolice) then return end if sell then
if inZone then Notify(Lang.Cornerselling.no, 'error') return end sell = false
local has = ps.callback('md-drugs:server:hasDrugs', false) ps.hideText()
if has then ps.notify(ps.lang('Cornerselling.stopped', 'error'))
if sell then
TriggerServerEvent('md-drugs:server:cornerselling:stop')
Notify(Lang.Cornerselling.stop, 'error')
sell = false
active = false
else
sell = true
Notify(Lang.Cornerselling.start, 'success')
repeat
Wait(1000)
Cornersell()
until not sell
end
else else
Notify(Lang.Cornerselling.nodrugs, 'error') sell = true
ps.notify(ps.lang('Cornerselling.started', 'success'))
Cornersell()
end end
end) end)
CreateThread(function() CreateThread(function()
for k, v in pairs (QBConfig.NoSellZones) do for k, v in pairs (QBConfig.NoSellZones) do
local box = lib.zones.box({ coords = v.loc, size = vec3(v.width, v.length, v.height), rotation = 180.0, debug = false, local box = lib.zones.box({ coords = v.loc, size = vec3(v.width, v.length, v.height), rotation = 180.0, debug = false,
onEnter = function() inZone = true end, onExit = function() inZone = false end}) onEnter = function() inZone = true end, onExit = function() inZone = false end})
end end
end)
RegisterNetEvent('md-drugs:client:cornerselling:remove', function(ped)
DeletePed(ped)
end) end)
+120 -63
View File
@@ -2,20 +2,79 @@ local PoppyPlants = {}
local herointable = false local herointable = false
local dirty = false local dirty = false
local function pickher(loc)
if not ps.progressbar(Lang.Heroin.pick, 4000, 'uncuff') then return end
TriggerServerEvent("heroin:pickupCane", loc)
end
local function pickOps(loc)
return {
{
icon = "fa-solid fa-seedling",
label = ps.lang('Heroin.pick'),
action = function() pickher(loc) end
}
}
end
local function createLabKit(coord, head) local function createLabKit(coord, head)
local heroinlabkit = CreateObject("v_ret_ml_tablea", coord.x, coord.y, coord.z - 1, true, false,false) local heroinlabkit = CreateObject("v_ret_ml_tablea", coord.x, coord.y, coord.z - 1, true, false,false)
SetEntityHeading(heroinlabkit, head) SetEntityHeading(heroinlabkit, head)
PlaceObjectOnGroundProperly(heroinlabkit) PlaceObjectOnGroundProperly(heroinlabkit)
AddMultiModel(heroinlabkit, { ps.entityTarget(heroinlabkit, {
{data = heroinlabkit, event = "md-drugs:client:heatliquidheroin", icon = "fa-solid fa-temperature-high", label = Lang.targets.heroin.cook, canInteract = function() if not dirty then return true end end}, {
{data = heroinlabkit, event = "md-drugs:client:getheroinkitback", icon = "fas fa-box-circle-check", label = Lang.targets.heroin.up, canInteract = function() if not dirty then return true end end}, icon = "fa-solid fa-temperature-high",
{data = heroinlabkit, event = "md-drugs:client:cleanheroinlabkit",icon = "fa-solid fa-hand-sparkles",label = Lang.targets.heroin.clean,canInteract = function() if dirty then return true end end}},heroinlabkit) label = ps.lang('Heroin.cook'),
action = function()
if not ps.hasItem('emptyvial') then return end
if not minigame() then
dirty = true
TriggerServerEvent("md-drugs:server:failheatingheroin")
ps.requestPTFX("core")
local heroinkit = StartParticleFxLoopedOnEntity("exp_air_molotov", heroinlabkit, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false)
SetParticleFxLoopedAlpha(heroinkit, 3.0)
SetPedToRagdoll(PlayerPedId(), 1300, 1300, 0, 0, 0, 0)
return end
if not ps.progressbar(ps.lang('Heroin.success'), 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:heatliquidheroin")
end,
canInteract = function()
if not dirty then return true end
return false
end
},
{
icon = "fas fa-box-circle-check",
label = ps.lang('Heroin.up'),
action = function()
if not ps.progressbar(ps.lang('Heroin.pickup'), 4000, 'uncuff') then return end
herointable = false
DeleteObject(heroinlabkit)
TriggerServerEvent("md-drugs:server:getheroinlabkitback")
end,
canInteract = function()
if not dirty then return true end
return false
end
},
{
event = "md-drugs:client:cleanheroinlabkit",
icon = "fa-solid fa-hand-sparkles",
label = ps.lang('Heroin.clean'),
action = function()
if not ps.hasItem('cleaningkit') then return end
if not ps.progressbar(ps.lang('Heroin.clean'), 4000, 'clean') then return end
local done = ps.callback('removeCleaningkit', false)
if done then dirty = false end
end,
canInteract = function()
if dirty then return true end
return false
end
}})
end end
local function pickher(loc)
if not progressbar(Lang.Heroin.pick, 4000, 'uncuff') then return end
TriggerServerEvent("heroin:pickupCane", loc)
end
RegisterNetEvent('heroin:respawnCane', function(loc) RegisterNetEvent('heroin:respawnCane', function(loc)
local v = GlobalState.PoppyPlants[loc] local v = GlobalState.PoppyPlants[loc]
@@ -23,7 +82,7 @@ RegisterNetEvent('heroin:respawnCane', function(loc)
if not PoppyPlants[loc] then if not PoppyPlants[loc] then
PoppyPlants[loc] = CreateObject(hash, v.location, false, true, true) PoppyPlants[loc] = CreateObject(hash, v.location, false, true, true)
Freeze(PoppyPlants[loc], true, v.heading) Freeze(PoppyPlants[loc], true, v.heading)
AddSingleModel(PoppyPlants[loc], {icon = "fa-solid fa-seedling", label = Lang.targets.heroin.pick, action = function() pickher(loc) end}, loc ) ps.entityTarget(PoppyPlants[loc], pickOps(loc), loc)
end end
end) end)
@@ -39,7 +98,7 @@ RegisterNetEvent("heroin:init", function()
if not v.taken then if not v.taken then
PoppyPlants[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true) PoppyPlants[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true)
Freeze(PoppyPlants[k], true, v.heading) Freeze(PoppyPlants[k], true, v.heading)
AddSingleModel(PoppyPlants[k], {icon = "fa-solid fa-seedling", label = Lang.targets.heroin.pick, action = function() pickher(k) end}, k ) ps.entityTarget(PoppyPlants[k], pickOps(k))
end end
end end
end) end)
@@ -55,73 +114,71 @@ end)
end end
end) end)
RegisterNetEvent("md-drugs:client:dryplant", function(data) for k, v in pairs (GlobalState.MDDrugsLocs.dryplant) do
if not progressbar(Lang.Heroin.dryout, 4000, 'uncuff') then return end ps.boxTarget('dryHeroin'..k, v.loc, {length = v.l, width = v.w, height = 1.0, rotation = v.rot}, {
TriggerServerEvent("md-drugs:server:dryplant",data.data) {
end) label = ps.lang('targets.heroin.dry'),
icon = 'fa-solid fa-temperature-high',
action = function()
if not ps.progressbar(ps.lang('Heroin.dryout'), 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:dryplant", k)
end,
canInteract = function()
return handleGang(v.gang)
end
}
})
end
RegisterNetEvent("md-drugs:client:cutheroin", function(data) for k, v in pairs (GlobalState.MDDrugsLocs.cutheroinone) do
if not ItemCheck('bakingsoda') then return end ps.boxTarget('cutHeroin'..k, v.loc, {length = v.l, width = v.w, height = 1.0, rotation = v.rot}, {
if not progressbar(Lang.Heroin.cutting, 4000, 'uncuff') then return end {
TriggerServerEvent("md-drugs:server:cutheroin", data.data) label = ps.lang('targets.heroin.cut'),
end) icon = 'fa-solid fa-seedling',
action = function()
if not ps.hasItem('bakingsoda') then return end
if not ps.progressbar(ps.lang('Heroin.cutting'), 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:cutheroin", k)
end,
canInteract = function()
return handleGang(v.gang)
end
}
})
end
RegisterNetEvent("md-drugs:client:buyheroinlabkit", function() RegisterNetEvent("md-drugs:client:buyheroinlabkit", function()
if not progressbar(Lang.Heroin.secret, 4000, 'uncuff') then return end if not ps.progressbar(ps.lang('Heroin.secret'), 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:getheroinlabkit") TriggerServerEvent("md-drugs:server:getheroinlabkit")
end) end)
ps.registerCallback("md-drugs:client:setheroinlabkit", function() ps.registerCallback("md-drugs:client:setheroinlabkit", function()
if herointable then if herointable then
Notify(Lang.Heroin.tableout, 'error') ps.notify(ps.lang('Heroin.tableout'), 'error')
return false return false
else else
herointable = true herointable = true
local location, head = StartRay() local location, head = StartRay()
if not location then herointable = false return end if not location then herointable = false return end
if not progressbar(Lang.Heroin.table, 4000, 'uncuff') then return end if not ps.progressbar(ps.lang('Heroin.table'), 4000, 'uncuff') then return end
createLabKit(location, head) createLabKit(location, head)
return true, location return true, location
end end
end) end)
RegisterNetEvent("md-drugs:client:heatliquidheroin", function(data) for k, v in pairs (GlobalState.MDDrugsLocs.fillneedle) do
local loc, head = GetEntityCoords(data.data), GetEntityHeading(data.data) ps.boxTarget('fillNeedle'..k, v.loc, {length = v.l, width = v.w, height = 1.0, rotation = v.rot}, {
if not ItemCheck('emptyvial') then return end {
if not minigame() then label = ps.lang('targets.heroin.fill'),
dirty = true icon = 'fa-solid fa-syringe',
TriggerServerEvent("md-drugs:server:failheatingheroin") action = function()
loadParticle("core") if not minigame() then TriggerServerEvent("md-drugs:server:failheroin", k) return end
local heroinkit = StartParticleFxLoopedOnEntity("exp_air_molotov", data.data, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false) if not ps.progressbar(ps.lang('Heroin.needles'), 4000, 'uncuff') then return end
SetParticleFxLoopedAlpha(heroinkit, 3.0) TriggerServerEvent("md-drugs:server:fillneedle", k)
SetPedToRagdoll(PlayerPedId(), 1300, 1300, 0, 0, 0, 0) end,
return end canInteract = function()
if not progressbar(Lang.Heroin.success, 4000, 'uncuff') then return end return handleGang(v.gang)
TriggerServerEvent("md-drugs:server:heatliquidheroin") end
end) }
})
RegisterNetEvent("md-drugs:client:cleanheroinlabkit", function(data) end
if not ItemCheck('cleaningkit') then return end
if not progressbar(Lang.Heroin.clean, 4000, 'clean') then return end
local done = ps.callback('removeCleaningkit', false)
if done then dirty = false end
end)
RegisterNetEvent("md-drugs:client:deletedirtyheroin", function(data)
local location,head = GetEntityCoords(data), GetEntityHeading(data)
DeleteObject(data)
createLabKit(location, head)
end)
RegisterNetEvent("md-drugs:client:getheroinkitback", function(data)
if not progressbar(Lang.Heroin.pickup, 4000, 'uncuff') then return end
herointable = false
DeleteObject(data.data)
TriggerServerEvent("md-drugs:server:getheroinlabkitback")
end)
RegisterNetEvent("md-drugs:client:fillneedle", function(data)
if not minigame() then TriggerServerEvent("md-drugs:server:failheroin", data.data) return end
if not progressbar(Lang.Heroin.needles, 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:fillneedle", data.data)
end)
+2
View File
@@ -12,6 +12,8 @@ client_scripts {
server_scripts { server_scripts {
'server/functions.lua', 'server/functions.lua',
'server/locations.lua',
'server/recipes.lua',
'serverRun.lua', 'serverRun.lua',
'@oxmysql/lib/MySQL.lua', '@oxmysql/lib/MySQL.lua',
} }
+85 -58
View File
@@ -1,4 +1,4 @@
local QBCore = exports['qb-core']:GetCoreObject()
local DrugDeals = {} local DrugDeals = {}
local Drugs = { local Drugs = {
["weed_white-widow"] = {rep = 1,min = 15, max = 24 }, ["weed_white-widow"] = {rep = 1,min = 15, max = 24 },
@@ -121,75 +121,108 @@ local Drugs = {
["cupofdextro"] = {rep = 1,min = 18, max = 40}, ["cupofdextro"] = {rep = 1,min = 18, max = 40},
} }
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped) local drugsNames = {}
local Player = getPlayer(source) for k, v in pairs(Drugs) do
local rep = getRep(source, 'cornerselling') table.insert(drugsNames, k)
if not Player then return nil end end
local type = 0 GlobalState.DrugNames = drugsNames
for k, v in pairs(Drugs) do local robChance = 1 -- Chance To Be Robbed
local item = Player.Functions.GetItemByName(k) local RobbedDrugs = {}
if item and type == 0 then
type = type + 1 local function beingRobbed(source, item, amount, ped)
Log(GetName(source) .. ' Allowed To Sell ' .. item.name .. '!' , 'cornerselling') local src = source
local amount = math.random(1,item.amount) local math = math.random(1,100)
if amount >= 15 then amount = 15 end if math <= robChance then
local price = math.random(Drugs[k]['min'], Drugs[k]['max']) * amount ps.removeItem(src, item, amount)
local result = math.floor(price * rep.price) ps.notify(src, 'You Got Robbed Nerd', 'error')
table.insert(DrugDeals, {item = item.name, amount = amount, price = result, cid = Player.PlayerData.citizenid, ped = ped}) RobbedDrugs[ps.getIdentifier(source)] = {item = item, amount = amount, ped = ped}
return {item = item.name, amount = amount, price = result, ped = ped} return true
else
return false
end
end
local function getDrugBack(source, item, amount)
local src = source
if RobbedDrugs[ps.getIdentifier(source)] then
if RobbedDrugs[ps.getIdentifier(source)].item == item and RobbedDrugs[ps.getIdentifier(source)].amount == amount then
ps.addItem(src, item, amount)
ps.notify(src, 'You Got Your Drugs Back', 'success')
RobbedDrugs[ps.getIdentifier(source)] = nil
return true
end end
end end
if type == 0 then end
return {item = 'nothing', amount = 0, price = 0, ped = ped}
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
local Player = ps.getPlayer(source)
local rep = getRep(source, 'cornerselling')
if not Player then return nil end
for k, v in pairs(Drugs) do
local item = ps.getItemCount(source, k) or 0
if item >= 1 then
local maths = math.random(1,100)
if maths <= robChance then
beingRobbed(source, k, item, ped)
return 'robbed'
else
if item > 15 then item = 15 end
local amount = math.random(1, item)
local price = (math.random(Drugs[k]['min'], Drugs[k]['max']) * amount) * rep.price
DrugDeals[ps.getIdentifier(source)] = {item = k, amount = amount, price = math.floor(price), ped = ped}
return DrugDeals[ps.getIdentifier(source)]
end
end
end end
return false
end) end)
ps.registerCallback('md-drugs:server:hasDrugs', function(source) ps.registerCallback('md-drugs:server:hasDrugs', function(source)
local Player = getPlayer(source)
for k, v in pairs(Drugs) do for k, v in pairs(Drugs) do
local item = Player.Functions.GetItemByName(k) if hasItem(source, k, 1) then
if item then
return true return true
end end
end end
return false return false
end) end)
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price) local function csCheck(src, item, amount, price)
local src = source
local Player = getPlayer(src)
local isIn = false local isIn = false
for k, v in pairs (Drugs) do for k, v in pairs (Drugs) do
if item == k then if item == k then
isIn = true isIn = true
end end
end end
if not isIn then return end if not isIn then return false end
for k, v in pairs (DrugDeals) do
if v.cid == Player.PlayerData.citizenid then if DrugDeals[ps.getIdentifier(src)] then
if v.item == item then if DrugDeals[ps.getIdentifier(src)].item == item and DrugDeals[ps.getIdentifier(src)].amount == amount and DrugDeals[ps.getIdentifier(src)].price == price then
if v.amount == amount then return true
if v.price == price then
if RemoveItem(src, item, amount) then
if QBConfig.MarkedBills then
local info = {
worth = price
}
Player.Functions.AddItem('markedbills', 1, false, info )
elseif QBConfig.CustomDirtyMoney == true then
AddItem(src, QBConfig.CustomDirtyMoneyitem, price)
else
Player.Functions.AddMoney('cash', price)
end
AddRep(src, 'cornerselling', Drugs[item].rep * amount)
Log(GetName(src) .. ' Sold ' .. amount .. ' Of ' .. item .. ' For A Price Of ' .. price .. '!' , 'cornerselling')
table.remove(DrugDeals, k)
end
end
end
end
end end
end end
return false
end
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price)
local src = source
if not csCheck(src, item, amount, price) then return end
if not ps.removeItem(src, item, amount) then
ps.notify(src, 'You Do Not Have Enough Of This Item', 'error')
DrugDeals[ps.getIdentifier(src)] = nil
return
end
--AddRep(src, 'cornerselling', Drugs[item].rep * amount)
Log(string.format('%s Sold %s Of %s For A Price Of $%s !', GetName(src),amount, item, price), 'cornerselling')
DrugDeals[ps.getIdentifier(src)] = nil
ps.addMoney(src, 'cash', price)
end)
RegisterNetEvent('md-drugs:server:getBackRobbed', function()
local tabl = RobbedDrugs[ps.getIdentifier(source)]
if tabl == nil then return end
getDrugBack(source, tabl.item, tabl.amount)
RobbedDrugs[ps.getIdentifier(source)] = nil
end) end)
lib.addCommand('cornersell', { lib.addCommand('cornersell', {
@@ -198,18 +231,12 @@ lib.addCommand('cornersell', {
}, },
}, function(source, args, raw) }, function(source, args, raw)
local src = source local src = source
local Player = getPlayer(src)
Log(GetName(source) .. ' Used Command cornersell!' , 'cornerselling')
TriggerClientEvent('md-drugs:client:cornerselling', src) TriggerClientEvent('md-drugs:client:cornerselling', src)
end) end)
RegisterServerEvent('md-drugs:server:cornerselling:stop', function() RegisterServerEvent('md-drugs:server:cornerselling:stop', function()
local src = source local src = source
local Player = getPlayer(src) if DrugDeals[ps.getIdentifier(src)] then
for k, v in pairs (DrugDeals) do DrugDeals[ps.getIdentifier(src)] = nil
if v.cid == Player.PlayerData.citizenid then
TriggerClientEvent('md-drugs:client:cornerselling:remove', src, DrugDeals[k].ped)
table.remove(DrugDeals, k)
end
end end
end) end)
+314 -140
View File
@@ -1,14 +1,25 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore, ESX, qbx = {}, {}, nil
local notify = Config.Notify -- qb or ox local notify = Config.Notify -- qb or ox
local inventory = Config.Inventory -- qb or ox local inventory = Config.Inventory -- qb or ox
local invname = ''
------------------------------------------ logging stuff ------------------------------------------ logging stuff
local logs = false local logs = false
local logapi = GetConvar("fivemerrLogs", "") local logapi = GetConvar("fivemerrLogs", "")
local endpoint = 'https://api.fivemerr.com/v1/logs' local endpoint = 'https://api.fivemerr.com/v1/logs'
local headers = { local headers = {
['Authorization'] = logapi, ['Authorization'] = logapi,
['Content-Type'] = 'application/json', ['Content-Type'] = 'application/json',
} }
if Config.Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject()
elseif Config.Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
elseif Config.Framework == 'qbx' then
qbx = exports.qbx_core
end
CreateThread(function() CreateThread(function()
if logs then if logs then
@@ -24,17 +35,11 @@ end
end) end)
function Log(message, type) function Log(message, type)
if logs == false then return end if logs == false then return end
local buffer = { local buffer = { level = "info", message = message, resource = GetCurrentResourceName(),
level = "info", metadata = { drugs = type, playerid = source}
message = message,
resource = GetCurrentResourceName(),
metadata = {
drugs = type,
playerid = source
}
} }
SetTimeout(500, function() SetTimeout(500, function()
PerformHttpRequest(endpoint, function(status, _, _, response) PerformHttpRequest(endpoint, function(status, _, _, response)
if status ~= 200 then if status ~= 200 then
if type(response) == 'string' then if type(response) == 'string' then
@@ -43,29 +48,62 @@ if logs == false then return end
end end
end, 'POST', json.encode(buffer), headers) end, 'POST', json.encode(buffer), headers)
buffer = nil buffer = nil
end) end)
end end
---------------------------------------------------- inventory catcher
local invname = ''
CreateThread(function()
if GetResourceState('ps-inventory') == 'started' then
invname = 'ps-inventory'
elseif GetResourceState('qb-inventory') == 'started' then
invname = 'qb-inventory'
else
invname = 'inventory'
end
end)
------------------------------------ Player Stuff functions ------------------------------------ Player Stuff functions
function getPlayer(source) function getPlayer(source)
local src = source local src = source
local Player = QBCore.Functions.GetPlayer(src) if Config.Framework == 'qb' then
return Player local Player = QBCore.Functions.GetPlayer(src)
return Player
elseif Config.Framework == 'esx' then
local Player = ESX.GetPlayerFromId(src)
return Player
elseif Config.Framework == 'qbx' then
local Player = qbx:GetPlayer(source)
return Player
end
end end
function GetName(source) function getPlayerByCid(cid)
local Player = getPlayer(source) if Config.Framework == 'qb' then
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname local Player = QBCore.Functions.GetPlayerByCitizenId(cid)
return Player
elseif Config.Framework == 'esx' then
local Player = ESX.GetPlayerFromIdentifier(cid)
return Player
elseif Config.Framework == 'qbx' then
local Player = qbx:GetPlayerByCitizenId(cid)
return Player
end
end
function GetName(source)
local src = source
if Config.Framework == 'qb' then
local Player = getPlayer(src)
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
elseif Config.Framework == 'esx' then
local Player = getPlayer(src)
return Player.getName()
elseif Config.Framework == 'qbx' then
local Player = getPlayer(src)
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
end
end
function getCid(source)
local src = source
if Config.Framework == 'qb' then
local Player = getPlayer(src)
return Player.PlayerData.citizenid
elseif Config.Framework == 'esx' then
local Player = getPlayer(src)
return Player.getIdentifier()
elseif Config.Framework == 'qbx' then
local Player = getPlayer(src)
return Player.PlayerData.citizenid
end
end end
function GetCoords(source) function GetCoords(source)
@@ -78,7 +116,8 @@ function dist(source, coords)
local playerPed = GetPlayerPed(source) local playerPed = GetPlayerPed(source)
local pcoords = GetEntityCoords(playerPed) local pcoords = GetEntityCoords(playerPed)
local dist = #(pcoords - coords) local dist = #(pcoords - coords)
return dist
return dist
end end
function CheckDist(source, coords) function CheckDist(source, coords)
@@ -87,7 +126,7 @@ function CheckDist(source, coords)
local ok local ok
if #(pcoords - coords) < 4.0 then if #(pcoords - coords) < 4.0 then
return ok return ok
else else
DropPlayer(source, 'md-drugs: You Were A Total Of ' .. #(pcoords - coords) .. ' Too Far Away To Trigger This Event') DropPlayer(source, 'md-drugs: You Were A Total Of ' .. #(pcoords - coords) .. ' Too Far Away To Trigger This Event')
return false return false
end end
@@ -107,7 +146,7 @@ function Notifys(source, text, type)
end end
end end
function GetLabels(item) function GetLabels(item)
if inventory == 'qb' then if inventory == 'qb' then
return QBCore.Shared.Items[item].label return QBCore.Shared.Items[item].label
elseif inventory == 'ox' then elseif inventory == 'ox' then
@@ -117,7 +156,13 @@ function GetLabels(item)
end end
function CUI(item, useFunction) function CUI(item, useFunction)
QBCore.Functions.CreateUseableItem(item, useFunction) if Config.Framework == 'qb' then
QBCore.Functions.CreateUseableItem(item, useFunction)
elseif Config.Framework == 'esx' then
ESX.RegisterUsableItem(item, useFunction)
elseif Config.Framework == 'qbx' then
qbx:CreateUseableItem(item, useFunction)
end
end end
function Itemcheck(source, item, amount) function Itemcheck(source, item, amount)
@@ -131,9 +176,9 @@ function Itemcheck(source, item, amount)
return false return false
end end
elseif inventory == 'ox' then elseif inventory == 'ox' then
local items = exports.ox_inventory:GetItem(source, item, nil, false) local items = exports.ox_inventory:GetItem(source, item, nil, false)
if items.count >= amount then if items.count >= amount then
return true return true
else else
Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error') Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error')
return false return false
@@ -141,13 +186,55 @@ function Itemcheck(source, item, amount)
end end
end end
function hasItem(source, item, amount)
if inventory == 'qb' then
local Player = getPlayer(source)
local itemchecks = Player.Functions.GetItemByName(item)
if itemchecks and itemchecks.amount >= amount then
return true
else
return false
end
elseif inventory == 'ox' then
local items = exports.ox_inventory:GetItem(source, item, nil, false)
if items == nil then return false end
if items.count >= amount then
return true
else
return false
end
end
end
function getItemCount(source, item)
if inventory == 'qb' then
local Player = getPlayer(source)
local itemchecks = Player.Functions.GetItemByName(item)
if itemchecks then
return itemchecks.amount
else
return false
end
elseif inventory == 'ox' then
local items = exports.ox_inventory:GetItem(source, item, nil, false)
if items == nil then
print('You are missing ' .. item)
return 0
end
if items.count >= 1 then
return items.count
else
return 0
end
end
end
function RemoveItem(source, item, amount) function RemoveItem(source, item, amount)
if inventory == 'qb' then if inventory == 'qb' then
local Player = getPlayer(source) local Player = getPlayer(source)
if Player.Functions.RemoveItem(item, amount) then if Player.Functions.RemoveItem(item, amount) then
TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "remove", amount) TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "remove", amount)
return true return true
else else
Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error') Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error')
end end
elseif inventory == 'ox' then elseif inventory == 'ox' then
@@ -162,16 +249,14 @@ end
function AddItem(source, item, amount) function AddItem(source, item, amount)
if inventory == 'qb' then if inventory == 'qb' then
local Player = getPlayer(source) local Player = getPlayer(source)
if Player.Functions.AddItem(item, amount) then if Player.Functions.AddItem(item, amount) then
TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "add", amount) TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "add", amount)
return true return true
else else
print('Failed To Give Item: ' .. item .. ' Check Your qb-core/shared/items.lua') print('Failed To Give Item: ' .. item .. ' Check Your qb-core/shared/items.lua')
return false return false
end end
else else
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 if exports.ox_inventory:AddItem(source, item, amount) then
return true return true
else else
@@ -181,66 +266,85 @@ function AddItem(source, item, amount)
end end
end end
function addMoney(source, type, amount)
if Config.Framework == 'qb' then
local Player = getPlayer(source)
if Player.Functions.AddMoney(type, amount) then
return true
else
return false
end
elseif Config.Framework == 'esx' then
local Player = getPlayer(source)
if Player.addMoney(amount) then
return true
else
return false
end
elseif Config.Framework == 'qbx' then
if qbx:AddMoney(source, type, amount) then
return true
else
return false
end
end
end
function getRep(source, type) function removeMoney(source, type, amount)
local Player = getPlayer(source) if Config.Framework == 'qb' then
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid}) local Player = getPlayer(source)
if Player.Functions.RemoveMoney(type, amount) then
return true
else
return false
end
elseif Config.Framework == 'esx' then
if type == 'bank' then
print('Does Not Support Bank Funds Removing From ESX Defaulted To Cash')
end
local Player = getPlayer(source)
if Player.getMoney() >= amount then
Player.removeMoney(amount)
return true
else
return false
end
elseif Config.Framework == 'qbx' then
if qbx:RemoveMoney(source, type, amount) then
return true
else
return false
end
end
end
local function handleFresh(source)
local table = json.encode({
coke = 0,lsd = 0,heroin = 0,dealerrep = 0,
cornerselling = { price = QBConfig.SellLevel[1].price,rep = 0,label = QBConfig.SellLevel[1].label,level = 1}
})
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {getCid(source), table, GetName(source)})
Wait(1000)
return json.decode(table)
end
function getRep(source, type)
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
if not sql[1] then if not sql[1] then
local table = json.encode({ local new = handleFresh(source)
coke = Player.PlayerData.metadata.coke or 0, return new[type]
lsd = Player.PlayerData.metadata.lsd or 0,
heroin = Player.PlayerData.metadata.heroin or 0,
dealerrep = Player.PlayerData.metadata.dealerrep or 0,
cornerselling = {
price = QBConfig.SellLevel[1].price,
rep = 0,
label = QBConfig.SellLevel[1].label,
level = 1
}
})
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {Player.PlayerData.citizenid, table, GetName(source)})
Wait(1000)
return json.decode(table)
else else
local reps = json.decode(sql[1].drugrep) local reps = json.decode(sql[1].drugrep)
local rep = '' local rep = ''
if reps.coke == nil then rep = reps[1] else rep = reps end if reps.coke == nil then rep = reps[1] else rep = reps end
if type == 'coke' then return rep[type]
return rep.coke
elseif type == 'heroin' then
return rep.heroin
elseif type == 'lsd' then
return rep.lsd
elseif type == 'dealerrep' then
return rep.dealerrep
elseif type == 'cornerselling' then
return rep.cornerselling
else
print('^1 Error: No Valid Drug Rep Option Chosen')
end
return false
end end
end end
function GetAllRep(source) function GetAllRep(source)
local Player = getPlayer(source) local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid})
if not sql[1] then if not sql[1] then
local table = json.encode({ local new = handleFresh(source)
coke = Player.PlayerData.metadata.coke or 0, return new
lsd = Player.PlayerData.metadata.lsd or 0,
heroin = Player.PlayerData.metadata.heroin or 0,
dealerrep = Player.PlayerData.metadata.dealerrep or 0,
cornerselling = {
price = QBConfig.SellLevel[1].price,
rep = 0,
label = QBConfig.SellLevel[1].label,
level = 1
}
})
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {Player.PlayerData.citizenid, table, GetName(source)})
Wait(1000)
return json.decode(table)
else else
local rep = json.decode(sql[1].drugrep) local rep = json.decode(sql[1].drugrep)
if rep.coke == nil then return rep[1] end if rep.coke == nil then return rep[1] end
@@ -248,10 +352,10 @@ function GetAllRep(source)
end end
end end
function AddRep(source, type, amount) function AddRep(source, type, amount)
if not Config.TierSystem then return false end
if not amount then amount = 1 end if not amount then amount = 1 end
local Player = getPlayer(source) local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid})
local reps = json.decode(sql[1].drugrep) local reps = json.decode(sql[1].drugrep)
local update local update
local rep = '' local rep = ''
@@ -265,19 +369,15 @@ function AddRep(source, type, amount)
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = {label = v.label, price = v.price, rep = rep.cornerselling.rep + amount, level = k}}) update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = {label = v.label, price = v.price, rep = rep.cornerselling.rep + amount, level = k}})
end end
end end
end end
elseif type == 'coke' then if update == '' then return false end
update = json.encode({coke = rep.coke + amount, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = rep.cornerselling}) MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, getCid(source)})
elseif type == 'heroin' then return true
update = json.encode({coke = rep.coke, heroin = rep.heroin + amount, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = rep.cornerselling}) else
elseif type == 'lsd' then rep[type] = rep[type] + amount
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd +amount , dealerrep = rep.dealerrep, cornerselling = rep.cornerselling}) MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {json.encode(rep), getCid(source)})
elseif type == 'dealerrep' then return true
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep + amount, cornerselling = rep.cornerselling})
end end
if update == '' then return false end
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, Player.PlayerData.citizenid})
return true
end end
lib.addCommand('addCornerSellingTOREP', { lib.addCommand('addCornerSellingTOREP', {
@@ -290,17 +390,17 @@ lib.addCommand('addCornerSellingTOREP', {
local old = json.decode(v.drugrep) local old = json.decode(v.drugrep)
local get = old[1] or old local get = old[1] or old
table.insert(new, { table.insert(new, {
coke = get.coke, coke = get.coke,
lsd = get.lsd, lsd = get.lsd,
heroin = get.heroin, heroin = get.heroin,
dealerrep = get.dealerrep, dealerrep = get.dealerrep,
cornerselling = { cornerselling = {
price = QBConfig.SellLevel[1].price, price = QBConfig.SellLevel[1].price,
rep = 0, rep = 0,
label = QBConfig.SellLevel[1].label, label = QBConfig.SellLevel[1].label,
level = 1 level = 1
} }
}) })
local news = json.encode(new) local news = json.encode(new)
MySQL.query.await('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {news, v.cid}) MySQL.query.await('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {news, v.cid})
end end
@@ -314,39 +414,110 @@ end
function getCops() function getCops()
local amount = 0 local amount = 0
local players = QBCore.Functions.GetQBPlayers() if Config.Framework == 'qb' then
for k, v in pairs(players) do local players = QBCore.Functions.GetQBPlayers()
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then for k, v in pairs(players) do
amount = amount + 1 if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then
end amount = amount + 1
end
end
return amount
elseif Config.Framework == 'esx' then
local players = ESX.GetPlayers()
for k, v in pairs(players) do
local xPlayer = ESX.GetPlayerFromId(v)
if xPlayer.job.name == 'police' and xPlayer.job.onduty then
amount = amount + 1
end
end
return amount
elseif Config.Framework == 'qbx' then
return qbx:GetDutyCountType('leo')
end end
return amount
end end
ps.registerCallback('md-drugs:server:GetCoppers', function(source, cb, args) function getNear(src)
local amount = 0 if Config.Framework == 'qb' then
local players = QBCore.Functions.GetQBPlayers() local near = {}
for k, v in pairs(players) do local players = QBCore.Functions.GetPlayers()
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then for k, v in pairs (players) do
amount = amount + 1 local targ = QBCore.Functions.GetPlayerByCitizenId(v.PlayerData.citizenid)
end local tname = GetName(v.PlayerData.source)
local ped, tped = GetPlayerPed(src), GetPlayerPed(v.PlayerData.source)
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
if dist < 5.0 then
table.insert(near, {label = tname, value = targ.PlayerData.citizenid})
end
end
return near
elseif Config.Framework == 'esx' then
local near = {}
local players = ESX.GetPlayers()
for k, v in pairs (players) do
local targ = ESX.GetPlayerFromId(v)
local tname = GetName(v)
local ped, tped = GetPlayerPed(src), GetPlayerPed(v)
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
if dist < 5.0 then
table.insert(near, {label = tname, value = getCid(v)})
end
end
return near
elseif Config.Framework == 'qbx' then
local near = {}
local players = qbx:GetPlayers()
for k, v in pairs (players) do
local targ = qbx:GetPlayer(v)
local tname = GetName(v)
local ped, tped = GetPlayerPed(src), GetPlayerPed(v)
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
if dist < 5.0 then
table.insert(near, {label = tname, value = getCid(v)})
end
end
return near
end end
return amount end
function handleCornersell(source, item, amount, price)
if RemoveItem(source, item, amount) then
if inventory == 'qb' then
local Player = getPlayer(source)
if QBConfig.MarkedBills == true then
Player.Functions.AddItem('markedbills',1,false, {worth = price})
return true
end
if QBConfig.CustomDirtyMoney == true then
AddItem(source, QBConfig.CustomDirtyMoneyitem,price)
return true
end
Player.Functions.AddMoney('cash', price)
elseif inventory == 'ox' then
AddItem(source, 'black_money', price)
return true
end
else
return false
end
end
lib.callback.register('md-drugs:server:GetCoppers', function(source, cb, args)
return getCops()
end) end)
ps.registerCallback('md-drugs:server:GetRep', function(source, cb, args) lib.callback.register('md-drugs:server:GetRep', function(source, cb, args)
local src = source
local rep = GetAllRep(source) local rep = GetAllRep(source)
return rep return rep
end) end)
CreateThread(function() CreateThread(function()
if not GetResourceState('ox_lib'):find("start") then if GetResourceState('ps-inventory') == 'started' then
print('^1 ox_lib Is A Depndancy, Not An Optional ') invname = 'ps-inventory'
elseif GetResourceState('qb-inventory') == 'started' then
invname = 'qb-inventory'
else
invname = 'inventory'
end end
end)
CreateThread(function()
local url = "https://raw.githubusercontent.com/Mustachedom/md-drugs/main/version.txt" local url = "https://raw.githubusercontent.com/Mustachedom/md-drugs/main/version.txt"
local version = GetResourceMetadata('md-drugs', "version" ) local version = GetResourceMetadata('md-drugs', "version" )
PerformHttpRequest(url, function(err, text, headers) PerformHttpRequest(url, function(err, text, headers)
@@ -354,4 +525,7 @@ CreateThread(function()
print('^2 Your Version:' .. version .. ' | Current Version:' .. text .. '' ) print('^2 Your Version:' .. version .. ' | Current Version:' .. text .. '' )
end end
end, "GET", "", "") end, "GET", "", "")
if GetResourceState('ox_lib') ~= 'started' then
print('^1 ox_lib Is A Depndancy, Not An Optional ')
end
end) end)
+102 -102
View File
@@ -1,4 +1,5 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
local prices = { local prices = {
heroinlabkitprice = 10000 heroinlabkitprice = 10000
} }
@@ -38,10 +39,9 @@ function heroinCooldown(loc)
end end
ps.registerCallback('removeCleaningkit', function(source) ps.registerCallback('removeCleaningkit', function(source)
local Player = getPlayer(source)
for k, v in pairs(heroinLabKits) do for k, v in pairs(heroinLabKits) do
if v.ownerid == Player.PlayerData.citizenid then if v.ownerid == ps.getIdentifier(source) then
RemoveItem(source, 'cleaningkit', 1) ps.removeItem(source, 'cleaningkit', 1)
return true return true
end end
end end
@@ -49,20 +49,21 @@ ps.registerCallback('removeCleaningkit', function(source)
end) end)
RegisterServerEvent("heroin:pickupCane", function(loc) RegisterServerEvent("heroin:pickupCane", function(loc)
if CheckDist(source, h[loc].location) then return end local src = source
if ps.checkDistance(src, h[loc].location, 3.0) then return end
if not h[loc].taken then if not h[loc].taken then
h[loc].taken = true h[loc].taken = true
GlobalState.PoppyPlants = h GlobalState.PoppyPlants = h
TriggerClientEvent("heroin:removeCane", -1, loc) TriggerClientEvent("heroin:removeCane", -1, loc)
heroinCooldown(loc) heroinCooldown(loc)
AddItem(source, 'poppyresin', 1) ps.addItem(src, 'poppyresin', 1)
end end
end) end)
RegisterServerEvent('md-drugs:server:dryplant', function(num) RegisterServerEvent('md-drugs:server:dryplant', function(num)
local src = source local src = source
if not checkLoc(source, 'dryplant', num) then return end if not ps.checkDistance(src, GlobalState.MDDrugsLocs.dryplant[num].loc, 3.0) then return end
if not Itemcheck(source, 'poppyresin', 1) then return end if not ps.hasItem(src, 'poppyresin', 1) then return end
if Config.TierSystem then if Config.TierSystem then
local heroin = getRep(src, 'heroin') local heroin = getRep(src, 'heroin')
if heroin <= Config.Tier1 then if heroin <= Config.Tier1 then
@@ -72,28 +73,28 @@ RegisterServerEvent('md-drugs:server:dryplant', function(num)
else else
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier3') then return end if not GetRecipe(src, 'heroin', 'dryheroin', 'tier3') then return end
end end
else return
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end
end end
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end
end) end)
RegisterServerEvent('md-drugs:server:cutheroin', function(num) RegisterServerEvent('md-drugs:server:cutheroin', function(num)
local src = source local src = source
local Player = getPlayer(src) if not ps.checkDistance(src, GlobalState.MDDrugsLocs.cutheroinone[num].loc, 3.0) then return end
if not checkLoc(source, 'cutheroinone', num) then return end if not ps.hasItem(src, 'bakingsoda', 1) then return end
if not Itemcheck(src, 'bakingsoda', 1) then return end
if Config.TierSystem then if Config.TierSystem then
local rawh = Player.Functions.GetItemByName('heroin') local itemList = {
local rawh2 = Player.Functions.GetItemByName('heroinstagetwo') heroin = 'tier1',
local rawh3 = Player.Functions.GetItemByName('heroinstagethree') heroinstagetwo = 'tier2',
if rawh then heroinstagethree = 'tier3'
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end }
elseif rawh2 then for k, v in pairs(itemList) do
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier2') then return end local cuth = ps.hasItem(src, k)
elseif rawh3 then if cuth then
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier3') then return end if not GetRecipe(src, 'heroin', 'cutheroin', v) then return end
else AddRep(src, 'heroin')
Notifys(src, Lang.Heroin.noheroin, "error") return
end
end end
else else
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end
@@ -102,22 +103,19 @@ end)
RegisterServerEvent('md-drugs:server:getheroinlabkit', function() RegisterServerEvent('md-drugs:server:getheroinlabkit', function()
local src = source local src = source
local Player = getPlayer(src) if not ps.checkDistance(src, GlobalState.MDDrugsLocs.singleSpot.buyheroinlabkit, 3.0) then return end
if not checkLoc(source, 'singleSpot', 'buyheroinlabkit') then return end local has = ps.hasItem(src, 'heroinlabkit')
local has = Player.Functions.GetItemByName('heroinlabkit') if has then ps.notify(src, Lang.Heroin.haskit, 'error') return end
if has then Notifys(src, Lang.Heroin.haskit, 'error') return end if ps.removeMoney(src, 'cash', prices.heroinlabkitprice) then
if Player.Functions.RemoveMoney('cash', prices.heroinlabkitprice) then ps.addItem(src, 'heroinlabkit', 1)
AddItem(src, 'heroinlabkit', 1)
else else
Notifys(src, 'You Need '.. prices.heroinlabkitprice .. ' In Cash For This', 'error') ps.notify(src, 'You Need '.. prices.heroinlabkitprice .. ' In Cash For This', 'error')
end end
end) end)
local function hasHKit(src) local function hasHKit(src)
local src = source
local Player = getPlayer(src)
for k, v in pairs(heroinLabKits) do for k, v in pairs(heroinLabKits) do
if v.ownerid == Player.PlayerData.citizenid then if v.ownerid == ps.getIdentifier(src) then
return true return true
end end
end end
@@ -126,51 +124,49 @@ end
RegisterServerEvent('md-drugs:server:getheroinlabkitback', function() RegisterServerEvent('md-drugs:server:getheroinlabkitback', function()
local src = source local src = source
local Player = getPlayer(src)
if not hasHKit(src) then return end if not hasHKit(src) then return end
for k, v in pairs (heroinLabKits) do for k, v in pairs (heroinLabKits) do
if v.ownerid == Player.PlayerData.citizenid then if v.ownerid == ps.getIdentifier(src) then
table.remove(heroinLabKits, k) table.remove(heroinLabKits, k)
AddItem(src, 'heroinlabkit', 1) ps.addItem(src, 'heroinlabkit', 1)
end end
end end
end) end)
CUI('heroinlabkit', function(source, item) ps.createUseable('heroinlabkit', function(source, item)
local src = source local src = source
local Player = getPlayer(src) if not ps.hasItem(src, 'heroinlabkit', 1) then return end
if not Itemcheck(source, 'heroinlabkit', 1) then return end
local placed, loc = ps.callback('md-drugs:client:setheroinlabkit', src) local placed, loc = ps.callback('md-drugs:client:setheroinlabkit', src)
if placed then if placed then
RemoveItem(src, 'heroinlabkit', 1) ps.removeItem(src, 'heroinlabkit', 1)
table.insert(heroinLabKits, { table.insert(heroinLabKits, {
src = src, src = src,
ownerid = Player.PlayerData.citizenid, ownerid = ps.getIdentifier(src),
coords = loc, coords = loc,
name = GetName(src) name = ps.getPlayerName(src)
}) })
Notifys(src, Lang.Heroin.placed, "success") ps.notify(src, Lang.Heroin.placed, "success")
end end
end) end)
RegisterServerEvent('md-drugs:server:heatliquidheroin', function() RegisterServerEvent('md-drugs:server:heatliquidheroin', function()
local src = source local src = source
local Player = getPlayer(src)
if not hasHKit(src) then return end if not hasHKit(src) then return end
if not Itemcheck(source, 'emptyvial', 1) then return end if not ps.itemCheck(src, 'emptyvial', 1) then return end
if Config.TierSystem then if Config.TierSystem then
local cuth = Player.Functions.GetItemByName('heroincut') local itemList = {
local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo') heroincut = 'tier1',
local cuth3 = Player.Functions.GetItemByName('heroincutstagethree') heroincutstagetwo = 'tier2',
if cuth then heroincutstagethree = 'tier3'
if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end }
elseif cuth2 then for k, v in pairs(itemList) do
if not GetRecipe(src, 'heroin', 'fillvial', 'tier2') then return end local cuth = ps.hasItem(src, k)
elseif cuth3 then if cuth then
if not GetRecipe(src, 'heroin', 'fillvial', 'tier3') then return end if not GetRecipe(src, 'heroin', 'fillvial', v) then return end
else AddRep(src, 'heroin')
Notifys(src, 'no cut heroin', "error") return
end
end end
else else
if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end
@@ -178,46 +174,46 @@ local Player = getPlayer(src)
end) end)
RegisterServerEvent('md-drugs:server:failheatingheroin', function() RegisterServerEvent('md-drugs:server:failheatingheroin', function()
local src = source local src = source
local Player = getPlayer(src) if not hasHKit(src) then return end
if not hasHKit(src) then return end local itemList = {
local cuth = Player.Functions.GetItemByName('heroincut') heroincut = 1,
local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo') heroincutstagetwo = 1,
local cuth3 = Player.Functions.GetItemByName('heroincutstagethree') heroincutstagethree = 1
if cuth then }
RemoveItem(src, 'heroincut', 1) for k, v in pairs(itemList) do
Notifys(src,Lang.Heroin.fail, "error") local cuth = ps.hasItem(src, k)
elseif cuth2 then if cuth then
RemoveItem(src, 'heroincutstagetwo', 1) ps.removeItem(src, k, v)
Notifys(src,Lang.Heroin.fail, "error") ps.notify(src, Lang.Heroin.fail, "error")
elseif cuth3 then return
RemoveItem(src, 'heroincutstagethree', 1) end
Notifys(src,Lang.Heroin.fail, "error")
end end
end) end)
RegisterServerEvent('md-drugs:server:fillneedle', function(num) RegisterServerEvent('md-drugs:server:fillneedle', function(num)
local src = source local src = source
local Player = getPlayer(src) if not ps.checkDistance(src, GlobalState.MDDrugsLocs.fillneedle[num].loc, 3.0) then
if not checkLoc(source, 'fillneedle', num) then return end ps.notify(src, Lang.Heroin.noloc, 'error')
if not Itemcheck(src, 'needle', 1) then return end return
end
if not ps.hasItem(src, 'needle', 1) then return end
if Config.TierSystem then if Config.TierSystem then
local heroin = getRep(src, 'heroin') local itemList = {
local vh = Player.Functions.GetItemByName('heroinvial') {item = 'heroinvial', tier = 'tier1', log = ' Filled Heroin Needle'},
local vh2 = Player.Functions.GetItemByName('heroinvialstagetwo') {item = 'heroinvialstagetwo', tier = 'tier2', log = ' Filled Heroin Needle tier 2'},
local vh3 = Player.Functions.GetItemByName('heroinvialstagethree') {item = 'heroinvialstagethree', tier = 'tier3', log = ' Filled Heroin Needle tier 3'}
if vh then }
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end for k, v in pairs(itemList) do
AddRep(src, 'heroin') local vh = ps.hasItem(src, v.item)
elseif vh2 then if vh then
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier2') then return end if not GetRecipe(src, 'heroin', 'fillneedle', v.tier) then return end
AddRep(src, 'heroin') AddRep(src, 'heroin')
elseif vh3 then Log(ps.getPlayerName(src) .. v.log, 'heroin')
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier3') then return end return
AddRep(src, 'heroin') end
else
Notifys(src,Lang.Heroin.nofill, "error")
end end
ps.notify(src,Lang.Heroin.nofill, "error")
else else
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end
end end
@@ -225,28 +221,32 @@ end)
RegisterServerEvent('md-drugs:server:failheroin', function() RegisterServerEvent('md-drugs:server:failheroin', function()
local src = source local src = source
local Player = getPlayer(src) Log(ps.getPlayerName(src) ..' Sucks And Burned Their Heroin', 'heroin')
Log(GetName(src) ..' Sucks And Burned Their Heroin', 'heroin')
if Config.TierSystem then if Config.TierSystem then
local vh = Player.Functions.GetItemByName('heroinvial') local itemList = {
local vh2 = Player.Functions.GetItemByName('heroinvialstagetwo') heroinvial = 1,
local vh3 = Player.Functions.GetItemByName('heroinvialstagethree') heroinvialstagetwo = 1,
if vh then RemoveItem(src, 'heroinvialstagethree', 1 ) heroinvialstagethree = 1
elseif vh2 then RemoveItem(src, 'heroinvialstagetwo', 1) }
elseif vh3 then RemoveItem(src, 'heroinvial', 1) for k, v in pairs (itemList) do
local cuth = ps.hasItem(src, k)
if cuth then
ps.removeItem(src, k, v)
ps.notify(src, Lang.Heroin.failneedle, "error")
return
end
end end
else else
RemoveItem(src, 'heroinvial', 1) ps.removeItem(src, 'heroinvial', 1)
end end
end) end)
AddEventHandler('playerDropped', function() AddEventHandler('playerDropped', function()
local src = source local src = source
local Player = getPlayer(src)
for k, v in pairs(heroinLabKits) do for k, v in pairs(heroinLabKits) do
if v.src == src then if v.src == src then
table.remove(heroinLabKits, k) table.remove(heroinLabKits, k)
AddItem(src, 'heroinlabkit', 1) ps.addItem(src, 'heroinlabkit', 1)
end end
end end
end) end)
+3 -3
View File
@@ -1,6 +1,6 @@
Config = {} --Ignore. Config = {} --Ignore.
ps = exports.ps_lib:init() ps = exports.ps_lib:init()
ps.insertLang("en") ps.loadLangs("en")
Config.respawnTime = 150 -- Seconds Config.respawnTime = 150 -- Seconds
Config.Fuel = "LegacyFuel" -- type the name of script you use i.e. ps-fuel, cdn-fuel, LegacyFuel Config.Fuel = "LegacyFuel" -- type the name of script you use i.e. ps-fuel, cdn-fuel, LegacyFuel
Config.TierSystem = true -- allows for three tiers of certain drugs ( coke, heroin, crack, lsd) Config.TierSystem = true -- allows for three tiers of certain drugs ( coke, heroin, crack, lsd)
@@ -54,8 +54,8 @@ Config.Drugs = {
cocaine = true, cocaine = true,
consumables =false, consumables =false,
crack = true, crack = true,
cornerselling = false, cornerselling = true,
heroin = false, heroin = true,
deliveries = false, deliveries = false,
lean = false, lean = false,
lsd = false, lsd = false,