- fix up heroin
This commit is contained in:
1 parent
1b29aaa3b0
commit
4fdef3cf30
8 files changed
+733
-414
No files matched your search
+20
-19
@@ -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}, {
|
||||||
{
|
{
|
||||||
|
|||||||
+140
-82
@@ -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)
|
|
||||||
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
|
|
||||||
sold = true
|
|
||||||
active = false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function walkAway(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
|
|
||||||
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)
|
||||||
|
|
||||||
|
if data == false then
|
||||||
|
sell = false
|
||||||
|
return
|
||||||
|
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()
|
canInteract = function()
|
||||||
if not targbusy then return true end end,
|
if IsEntityDead(targ) and not got then
|
||||||
},
|
return true
|
||||||
{ label = Lang.targets.CornerSell.deny, icon = "fa-solid fa-person-harassing",
|
end
|
||||||
action = function() deny(targ) end,
|
end,
|
||||||
canInteract = function()
|
|
||||||
if not targbusy 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 inZone then Notify(Lang.Cornerselling.no, 'error') return end
|
|
||||||
local has = ps.callback('md-drugs:server:hasDrugs', false)
|
|
||||||
if has then
|
|
||||||
if sell then
|
if sell then
|
||||||
TriggerServerEvent('md-drugs:server:cornerselling:stop')
|
|
||||||
Notify(Lang.Cornerselling.stop, 'error')
|
|
||||||
sell = false
|
sell = false
|
||||||
active = false
|
ps.hideText()
|
||||||
|
ps.notify(ps.lang('Cornerselling.stopped', 'error'))
|
||||||
else
|
else
|
||||||
sell = true
|
sell = true
|
||||||
Notify(Lang.Cornerselling.start, 'success')
|
ps.notify(ps.lang('Cornerselling.started', 'success'))
|
||||||
repeat
|
|
||||||
Wait(1000)
|
|
||||||
Cornersell()
|
Cornersell()
|
||||||
until not sell
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Notify(Lang.Cornerselling.nodrugs, 'error')
|
|
||||||
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)
|
||||||
+119
-62
@@ -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)
|
|
||||||
@@ -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',
|
||||||
}
|
}
|
||||||
|
|||||||
+79
-52
@@ -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},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local drugsNames = {}
|
||||||
|
for k, v in pairs(Drugs) do
|
||||||
|
table.insert(drugsNames, k)
|
||||||
|
end
|
||||||
|
GlobalState.DrugNames = drugsNames
|
||||||
|
local robChance = 1 -- Chance To Be Robbed
|
||||||
|
local RobbedDrugs = {}
|
||||||
|
|
||||||
|
local function beingRobbed(source, item, amount, ped)
|
||||||
|
local src = source
|
||||||
|
local math = math.random(1,100)
|
||||||
|
if math <= robChance then
|
||||||
|
ps.removeItem(src, item, amount)
|
||||||
|
ps.notify(src, 'You Got Robbed Nerd', 'error')
|
||||||
|
RobbedDrugs[ps.getIdentifier(source)] = {item = item, amount = amount, 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
|
||||||
|
|
||||||
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
|
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
|
||||||
local Player = getPlayer(source)
|
local Player = ps.getPlayer(source)
|
||||||
local rep = getRep(source, 'cornerselling')
|
local rep = getRep(source, 'cornerselling')
|
||||||
if not Player then return nil end
|
if not Player then return nil end
|
||||||
local type = 0
|
|
||||||
for k, v in pairs(Drugs) do
|
for k, v in pairs(Drugs) do
|
||||||
local item = Player.Functions.GetItemByName(k)
|
local item = ps.getItemCount(source, k) or 0
|
||||||
if item and type == 0 then
|
if item >= 1 then
|
||||||
type = type + 1
|
local maths = math.random(1,100)
|
||||||
Log(GetName(source) .. ' Allowed To Sell ' .. item.name .. '!' , 'cornerselling')
|
if maths <= robChance then
|
||||||
local amount = math.random(1,item.amount)
|
beingRobbed(source, k, item, ped)
|
||||||
if amount >= 15 then amount = 15 end
|
return 'robbed'
|
||||||
local price = math.random(Drugs[k]['min'], Drugs[k]['max']) * amount
|
else
|
||||||
local result = math.floor(price * rep.price)
|
if item > 15 then item = 15 end
|
||||||
table.insert(DrugDeals, {item = item.name, amount = amount, price = result, cid = Player.PlayerData.citizenid, ped = ped})
|
local amount = math.random(1, item)
|
||||||
return {item = item.name, amount = amount, price = result, ped = ped}
|
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
|
||||||
if type == 0 then
|
|
||||||
return {item = 'nothing', amount = 0, price = 0, ped = ped}
|
|
||||||
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
|
||||||
|
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
|
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)
|
||||||
+270
-96
@@ -1,6 +1,8 @@
|
|||||||
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", "")
|
||||||
@@ -8,7 +10,16 @@ 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
|
||||||
@@ -25,14 +36,8 @@ 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)
|
||||||
@@ -45,27 +50,60 @@ if logs == false then return end
|
|||||||
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
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
return Player
|
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
|
||||||
|
|
||||||
|
function getPlayerByCid(cid)
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
|
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
|
end
|
||||||
|
|
||||||
function GetName(source)
|
function GetName(source)
|
||||||
local Player = getPlayer(source)
|
local src = source
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
|
local Player = getPlayer(src)
|
||||||
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
|
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,6 +116,7 @@ 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
|
||||||
|
|
||||||
@@ -117,7 +156,13 @@ function GetLabels(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CUI(item, useFunction)
|
function CUI(item, useFunction)
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
QBCore.Functions.CreateUseableItem(item, useFunction)
|
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)
|
||||||
@@ -141,6 +186,48 @@ 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)
|
||||||
@@ -170,8 +257,6 @@ function AddItem(source, item, amount)
|
|||||||
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)
|
||||||
function getRep(source, type)
|
if Config.Framework == 'qb' then
|
||||||
local Player = getPlayer(source)
|
local Player = getPlayer(source)
|
||||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid})
|
if Player.Functions.AddMoney(type, amount) then
|
||||||
if not sql[1] 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 removeMoney(source, type, amount)
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
|
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({
|
local table = json.encode({
|
||||||
coke = Player.PlayerData.metadata.coke or 0,
|
coke = 0,lsd = 0,heroin = 0,dealerrep = 0,
|
||||||
lsd = Player.PlayerData.metadata.lsd or 0,
|
cornerselling = { price = QBConfig.SellLevel[1].price,rep = 0,label = QBConfig.SellLevel[1].label,level = 1}
|
||||||
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)})
|
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {getCid(source), table, GetName(source)})
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
return json.decode(table)
|
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
|
||||||
|
local new = handleFresh(source)
|
||||||
|
return new[type]
|
||||||
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
|
||||||
@@ -249,9 +353,9 @@ function GetAllRep(source)
|
|||||||
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 = ''
|
||||||
@@ -266,18 +370,14 @@ function AddRep(source, type, amount)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif type == 'coke' then
|
|
||||||
update = json.encode({coke = rep.coke + amount, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = rep.cornerselling})
|
|
||||||
elseif type == 'heroin' then
|
|
||||||
update = json.encode({coke = rep.coke, heroin = rep.heroin + amount, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = rep.cornerselling})
|
|
||||||
elseif type == 'lsd' then
|
|
||||||
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd +amount , dealerrep = rep.dealerrep, cornerselling = rep.cornerselling})
|
|
||||||
elseif type == 'dealerrep' then
|
|
||||||
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep + amount, cornerselling = rep.cornerselling})
|
|
||||||
end
|
|
||||||
if update == '' then return false end
|
if update == '' then return false end
|
||||||
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, Player.PlayerData.citizenid})
|
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, getCid(source)})
|
||||||
return true
|
return true
|
||||||
|
else
|
||||||
|
rep[type] = rep[type] + amount
|
||||||
|
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {json.encode(rep), getCid(source)})
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.addCommand('addCornerSellingTOREP', {
|
lib.addCommand('addCornerSellingTOREP', {
|
||||||
@@ -314,6 +414,7 @@ end
|
|||||||
|
|
||||||
function getCops()
|
function getCops()
|
||||||
local amount = 0
|
local amount = 0
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
local players = QBCore.Functions.GetQBPlayers()
|
local players = QBCore.Functions.GetQBPlayers()
|
||||||
for k, v in pairs(players) do
|
for k, v in pairs(players) do
|
||||||
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then
|
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then
|
||||||
@@ -321,32 +422,102 @@ function getCops()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return amount
|
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
|
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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
return amount
|
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
|
||||||
|
|
||||||
|
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)
|
||||||
+100
-100
@@ -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',
|
||||||
|
heroincutstagethree = 'tier3'
|
||||||
|
}
|
||||||
|
for k, v in pairs(itemList) do
|
||||||
|
local cuth = ps.hasItem(src, k)
|
||||||
if cuth then
|
if cuth then
|
||||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end
|
if not GetRecipe(src, 'heroin', 'fillvial', v) then return end
|
||||||
elseif cuth2 then
|
AddRep(src, 'heroin')
|
||||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier2') then return end
|
return
|
||||||
elseif cuth3 then
|
end
|
||||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier3') then return end
|
|
||||||
else
|
|
||||||
Notifys(src, 'no cut heroin', "error")
|
|
||||||
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
|
||||||
|
}
|
||||||
|
for k, v in pairs(itemList) do
|
||||||
|
local cuth = ps.hasItem(src, k)
|
||||||
if cuth then
|
if cuth then
|
||||||
RemoveItem(src, 'heroincut', 1)
|
ps.removeItem(src, k, v)
|
||||||
Notifys(src,Lang.Heroin.fail, "error")
|
ps.notify(src, Lang.Heroin.fail, "error")
|
||||||
elseif cuth2 then
|
return
|
||||||
RemoveItem(src, 'heroincutstagetwo', 1)
|
end
|
||||||
Notifys(src,Lang.Heroin.fail, "error")
|
|
||||||
elseif cuth3 then
|
|
||||||
RemoveItem(src, 'heroincutstagethree', 1)
|
|
||||||
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
|
||||||
if Config.TierSystem then
|
|
||||||
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
|
|
||||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end
|
|
||||||
AddRep(src, 'heroin')
|
|
||||||
elseif vh2 then
|
|
||||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier2') then return end
|
|
||||||
AddRep(src, 'heroin')
|
|
||||||
elseif vh3 then
|
|
||||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier3') then return end
|
|
||||||
AddRep(src, 'heroin')
|
|
||||||
else
|
|
||||||
Notifys(src,Lang.Heroin.nofill, "error")
|
|
||||||
end
|
end
|
||||||
|
if not ps.hasItem(src, 'needle', 1) then return end
|
||||||
|
if Config.TierSystem then
|
||||||
|
local itemList = {
|
||||||
|
{item = 'heroinvial', tier = 'tier1', log = ' Filled Heroin Needle'},
|
||||||
|
{item = 'heroinvialstagetwo', tier = 'tier2', log = ' Filled Heroin Needle tier 2'},
|
||||||
|
{item = 'heroinvialstagethree', tier = 'tier3', log = ' Filled Heroin Needle tier 3'}
|
||||||
|
}
|
||||||
|
for k, v in pairs(itemList) do
|
||||||
|
local vh = ps.hasItem(src, v.item)
|
||||||
|
if vh then
|
||||||
|
if not GetRecipe(src, 'heroin', 'fillneedle', v.tier) then return end
|
||||||
|
AddRep(src, 'heroin')
|
||||||
|
Log(ps.getPlayerName(src) .. v.log, 'heroin')
|
||||||
|
return
|
||||||
|
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
@@ -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,
|
||||||
|
|||||||
Reference in new issue
Block a user