Files
md-drugs/client/cocaine.lua
T

113 lines
3.8 KiB
Lua
Raw Normal View History

2024-01-13 22:23:17 -08:00
local CocaPlant = {}
local cuttingcoke = nil
2024-09-17 13:01:17 -07:00
local baggingcoke = nil
2025-07-14 01:34:58 -07:00
2024-09-17 13:01:17 -07:00
local function pick(loc)
2024-10-23 17:49:03 -07:00
if not progressbar(Lang.Coke.picking, 4000, 'uncuff') then return end
2025-06-30 23:24:57 -07:00
TriggerServerEvent("coke:pickupCane", loc)
2024-10-23 17:49:03 -07:00
return true
2024-09-17 13:01:17 -07:00
end
2024-01-13 22:23:17 -08:00
2025-07-14 01:34:58 -07:00
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
2024-01-13 22:23:17 -08:00
RegisterNetEvent('coke:respawnCane', function(loc)
local v = GlobalState.CocaPlant[loc]
local hash = GetHashKey(v.model)
if not CocaPlant[loc] then
CocaPlant[loc] = CreateObject(hash, v.location, false, true, true)
Freeze(CocaPlant[loc], true, v.heading)
2025-07-14 01:34:58 -07:00
ps.entityTarget(CocaPlant[loc], targetOps(loc))
2024-01-13 22:23:17 -08:00
end
end)
RegisterNetEvent('coke:removeCane', function(loc)
if DoesEntityExist(CocaPlant[loc]) then DeleteEntity(CocaPlant[loc]) end
CocaPlant[loc] = nil
end)
RegisterNetEvent("coke:init", function()
for k, v in pairs (GlobalState.CocaPlant) do
local hash = GetHashKey(v.model)
2025-07-01 03:09:46 -07:00
ps.requestModel(hash)
2024-01-13 22:23:17 -08:00
if not v.taken then
CocaPlant[k] = CreateObject(hash, v.location.x, v.location.y, v.location.z, false, true, true)
2024-07-11 17:39:58 -07:00
Freeze(CocaPlant[k], true, v.heading)
2025-07-14 01:34:58 -07:00
ps.entityTarget(CocaPlant[k], targetOps(k))
2024-01-13 22:23:17 -08:00
end
2024-09-17 13:01:17 -07:00
end
2024-01-13 22:23:17 -08:00
end)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01a'))
for k, v in pairs(CocaPlant) do
if DoesEntityExist(v) then
DeleteEntity(v) SetEntityAsNoLongerNeeded(v)
end
end
end
end)
2025-06-30 23:24:57 -07:00
for k, v in pairs (GlobalState.MDDrugsLocs.MakePowder) do
ps.boxTarget('cocaplant'..k, v.loc, {length = v.l, width = v.w, height = 1.0, rotation = v.rot}, {
{
2025-07-01 03:09:46 -07:00
label = ps.lang('.targets.coke.pick'),
2025-06-30 23:24:57 -07:00
icon = 'fa-solid fa-seedling',
action = function()
2025-07-14 01:34:58 -07:00
if not ps.hasItem('coca_leaf') then
ps.notify('You Need A Coke Leaf')
return
end
2025-07-01 03:09:46 -07:00
if not ps.progressbar(ps.lang('Coke.makepow'), 4000, 'uncuff') then return end
2025-06-30 23:24:57 -07:00
TriggerServerEvent("md-drugs:server:makepowder", k)
end,
canInteract = function()
return handleGang(v.gang)
end
}
})
end
2024-01-13 22:23:17 -08:00
2025-06-30 23:24:57 -07:00
for k, v in pairs (GlobalState.MDDrugsLocs.CuttingCoke) do
ps.boxTarget('cutcoke'..k, v.loc, {length = 1.0, width = 1.0, height = 1.0, rotation = 180.0}, {
{
2025-07-01 03:09:46 -07:00
label = ps.lang('targets.coke.cut'),
2025-06-30 23:24:57 -07:00
icon = 'fa-solid fa-mortar-pestle',
action = function()
CutCoke(v.loc, v.offset, v.rotation)
end,
canInteract = function()
if not handleGang(v.gang) then return false end
if cuttingcoke ~= nil or baggingcoke ~= nil then return false end
return true
end,
}
})
end
2025-07-14 01:34:58 -07:00
2025-06-30 23:24:57 -07:00
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}, {
{
2025-07-01 03:09:46 -07:00
label = ps.lang('targets.coke.bag'),
2025-06-30 23:24:57 -07:00
icon = 'fa-solid fa-sack-xmark',
action = function()
BagCoke(v.loc, v.offset, v.rotation)
end,
canInteract = function()
if not handleGang(v.gang) then return false end
if cuttingcoke ~= nil or baggingcoke ~= nil then return false end
return true
end
}
})
2025-07-14 01:34:58 -07:00
end