2024-01-13 22:23:17 -08:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
local PoppyPlants = {}
|
2024-03-17 20:05:09 -07:00
|
|
|
local herointable = false
|
2024-09-24 15:07:41 -07:00
|
|
|
|
2024-10-25 01:55:35 -07:00
|
|
|
local function createLabKit(coord, head)
|
2024-10-25 11:41:59 -07:00
|
|
|
local heroinlabkit = CreateObject("v_ret_ml_tablea", coord.x, coord.y, coord.z - 1, true, false,false)
|
2024-10-25 01:55:35 -07:00
|
|
|
SetEntityHeading(heroinlabkit, head)
|
|
|
|
|
PlaceObjectOnGroundProperly(heroinlabkit)
|
2024-11-12 17:08:02 -08:00
|
|
|
AddMultiModel(heroinlabkit, {
|
2024-10-28 14:35:47 -07:00
|
|
|
{ event = "md-drugs:client:heatliquidheroin", icon = "fa-solid fa-temperature-high", label = Lang.targets.heroin.cook, data = heroinlabkit},
|
2024-11-12 17:08:02 -08:00
|
|
|
{ event = "md-drugs:client:getheroinkitback", icon = "fas fa-box-circle-check", label = Lang.targets.heroin.up, data = heroinlabkit, canInteract = function() if herointable then return true end end}},
|
|
|
|
|
heroinlabkit)
|
2024-10-25 01:55:35 -07:00
|
|
|
end
|
2024-10-24 20:00:27 -07:00
|
|
|
|
2024-09-24 15:07:41 -07:00
|
|
|
local function pickher(loc)
|
|
|
|
|
if not progressbar(Lang.Heroin.pick, 4000, 'uncuff') then return end
|
|
|
|
|
TriggerServerEvent("heroin:pickupCane", loc)
|
2024-01-13 22:23:17 -08:00
|
|
|
end
|
2024-09-24 15:07:41 -07:00
|
|
|
|
2024-01-13 22:23:17 -08:00
|
|
|
RegisterNetEvent('heroin:respawnCane', function(loc)
|
|
|
|
|
local v = GlobalState.PoppyPlants[loc]
|
|
|
|
|
local hash = GetHashKey(v.model)
|
|
|
|
|
if not PoppyPlants[loc] then
|
|
|
|
|
PoppyPlants[loc] = CreateObject(hash, v.location, false, true, true)
|
2024-07-11 17:39:58 -07:00
|
|
|
Freeze(PoppyPlants[loc], true, v.heading)
|
2024-10-28 14:35:47 -07:00
|
|
|
AddSingleModel(PoppyPlants[loc], {icon = "fa-solid fa-seedling", label = Lang.targets.heroin.pick, action = function() pickher(loc) end}, loc )
|
2024-01-13 22:23:17 -08:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('heroin:removeCane', function(loc)
|
|
|
|
|
if DoesEntityExist(PoppyPlants[loc]) then DeleteEntity(PoppyPlants[loc]) end
|
|
|
|
|
PoppyPlants[loc] = nil
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent("heroin:init", function()
|
|
|
|
|
for k, v in pairs (GlobalState.PoppyPlants) do
|
|
|
|
|
local hash = GetHashKey(v.model)
|
|
|
|
|
if not HasModelLoaded(hash) then LoadModel(hash) end
|
|
|
|
|
if not v.taken then
|
|
|
|
|
PoppyPlants[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true)
|
2024-07-11 17:39:58 -07:00
|
|
|
Freeze(PoppyPlants[k], true, v.heading)
|
2024-10-28 14:35:47 -07:00
|
|
|
AddSingleModel(PoppyPlants[k], {icon = "fa-solid fa-seedling", label = Lang.targets.heroin.pick, action = function() pickher(k) end}, k )
|
2024-01-13 22:23:17 -08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
AddEventHandler('onResourceStop', function(resourceName)
|
|
|
|
|
if GetCurrentResourceName() == resourceName then
|
|
|
|
|
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01b'))
|
|
|
|
|
for k, v in pairs(PoppyPlants) do
|
|
|
|
|
if DoesEntityExist(v) then
|
|
|
|
|
DeleteEntity(v) SetEntityAsNoLongerNeeded(v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
2024-05-02 18:34:14 -07:00
|
|
|
|
|
|
|
|
RegisterNetEvent("md-drugs:client:dryplant", function(data)
|
|
|
|
|
if not progressbar(Lang.Heroin.dryout, 4000, 'uncuff') then return end
|
|
|
|
|
TriggerServerEvent("md-drugs:server:dryplant",data.data)
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-05-02 18:34:14 -07:00
|
|
|
RegisterNetEvent("md-drugs:client:cutheroin", function(data)
|
|
|
|
|
if not ItemCheck('bakingsoda') then return end
|
|
|
|
|
if not progressbar(Lang.Heroin.cutting, 4000, 'uncuff') then return end
|
|
|
|
|
TriggerServerEvent("md-drugs:server:cutheroin", data.data)
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-05-02 18:34:14 -07:00
|
|
|
RegisterNetEvent("md-drugs:client:buyheroinlabkit", function()
|
|
|
|
|
if not progressbar(Lang.Heroin.secret, 4000, 'uncuff') then return end
|
|
|
|
|
TriggerServerEvent("md-drugs:server:getheroinlabkit")
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-11-22 12:26:27 -08:00
|
|
|
lib.callback.register("md-drugs:client:setheroinlabkit", function()
|
2024-10-25 01:55:35 -07:00
|
|
|
if herointable then
|
|
|
|
|
Notify(Lang.Heroin.tableout, 'error')
|
2024-11-22 12:26:27 -08:00
|
|
|
return false
|
2024-10-25 01:55:35 -07:00
|
|
|
else
|
|
|
|
|
herointable = true
|
|
|
|
|
local location, head = StartRay()
|
2024-11-22 12:26:27 -08:00
|
|
|
if not location then herointable = false return end
|
|
|
|
|
if not progressbar(Lang.Heroin.table, 4000, 'uncuff') then return end
|
2024-10-25 01:55:35 -07:00
|
|
|
createLabKit(location, head)
|
2024-11-22 12:26:27 -08:00
|
|
|
return true, location
|
2024-10-25 01:55:35 -07:00
|
|
|
end
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-05-02 18:34:14 -07:00
|
|
|
RegisterNetEvent("md-drugs:client:heatliquidheroin", function(data)
|
2024-10-25 01:55:35 -07:00
|
|
|
local loc, head = GetEntityCoords(data.data), GetEntityHeading(data.data)
|
2024-05-02 18:34:14 -07:00
|
|
|
if not ItemCheck('emptyvial') then return end
|
2024-10-23 17:44:46 -07:00
|
|
|
if not minigame() then
|
2024-05-02 18:34:14 -07:00
|
|
|
TriggerServerEvent("md-drugs:server:failheatingheroin")
|
|
|
|
|
DeleteObject(data.data)
|
2024-09-24 15:07:41 -07:00
|
|
|
local dirtylabkitheroin = CreateObject("v_ret_ml_tablea", loc.x, loc.y, loc.z-1, true, false)
|
|
|
|
|
SetEntityHeading(dirtylabkitheroin, head)
|
|
|
|
|
PlaceObjectOnGroundProperly(dirtylabkitheroin)
|
2024-01-13 22:23:17 -08:00
|
|
|
loadParticle("core")
|
|
|
|
|
heroinkit = StartParticleFxLoopedOnEntity("exp_air_molotov", dirtylabkitheroin, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false)
|
|
|
|
|
SetParticleFxLoopedAlpha(heroinkit, 3.0)
|
2024-05-02 18:34:14 -07:00
|
|
|
SetPedToRagdoll(PlayerPedId(), 1300, 1300, 0, 0, 0, 0)
|
2024-11-04 17:43:48 -08:00
|
|
|
AddMultiModel(dirtylabkitheroin, {{event = "md-drugs:client:cleanheroinlabkit",icon = "fa-solid fa-hand-sparkles",label = Lang.targets.heroin.clean, data = dirtylabkitheroin}}, nil )
|
2024-05-02 18:34:14 -07:00
|
|
|
return end
|
2024-10-25 01:55:35 -07:00
|
|
|
if not progressbar(Lang.Heroin.success, 4000, 'uncuff') then return end
|
2024-05-02 18:34:14 -07:00
|
|
|
TriggerServerEvent("md-drugs:server:heatliquidheroin")
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-05-02 18:34:14 -07:00
|
|
|
RegisterNetEvent("md-drugs:client:cleanheroinlabkit", function(data)
|
|
|
|
|
if not ItemCheck('cleaningkit') then return end
|
|
|
|
|
if not progressbar(Lang.Heroin.clean, 4000, 'clean') then return end
|
|
|
|
|
TriggerServerEvent("md-drugs:server:removecleaningkitheroin", data.data)
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-09-24 15:07:41 -07:00
|
|
|
RegisterNetEvent("md-drugs:client:deletedirtyheroin", function(data)
|
2024-10-25 01:55:35 -07:00
|
|
|
local location,head = GetEntityCoords(data), GetEntityHeading(data)
|
2024-09-24 15:07:41 -07:00
|
|
|
DeleteObject(data)
|
2024-10-25 01:55:35 -07:00
|
|
|
createLabKit(location, head)
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-05-02 18:34:14 -07:00
|
|
|
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")
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-10-23 17:44:46 -07:00
|
|
|
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
|
2024-05-02 18:34:14 -07:00
|
|
|
TriggerServerEvent("md-drugs:server:fillneedle", data.data)
|
2024-10-25 01:55:35 -07:00
|
|
|
end)
|