Files
md-drugs/client/cocaine.lua
T

91 lines
4.0 KiB
Lua
Raw Normal View History

2024-01-13 22:23:17 -08:00
local QBCore = exports['qb-core']:GetCoreObject()
local CocaPlant = {}
local cuttingcoke = nil
2024-09-17 13:01:17 -07:00
local baggingcoke = nil
2024-08-26 15:49:35 -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
TriggerServerEvent("coke:pickupCane", loc)
return true
2024-09-17 13:01:17 -07:00
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)
2024-10-28 14:35:47 -07:00
AddSingleModel(CocaPlant[loc], {icon = "fa-solid fa-seedling", label = Lang.targets.coke.pick, action = function() if not pick(loc) then return end end}, 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)
2024-10-28 14:11:49 -07:00
LoadModel(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)
2024-10-28 14:35:47 -07:00
AddSingleModel(CocaPlant[k], {icon = "fa-solid fa-seedling", label = Lang.targets.coke.pick, action = function() if not pick(k) then return end end}, 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)
2024-05-02 18:34:14 -07:00
RegisterNetEvent("md-drugs:client:makepowder", function(data)
if not ItemCheck('coca_leaf') then return end
if not progressbar(Lang.Coke.makepow, 4000, 'uncuff') then return end
TriggerServerEvent("md-drugs:server:makepowder", data.data)
2024-01-13 22:23:17 -08:00
end)
2024-11-11 20:22:48 -08:00
RegisterNetEvent("md-drugs:client:cutcokeone", function(data)
2024-05-02 18:34:14 -07:00
if not ItemCheck('bakingsoda') then return end
2024-01-13 22:23:17 -08:00
cuttingcoke = true
2024-05-02 18:34:14 -07:00
if Config.FancyCokeAnims then
CutCoke()
else
if not progressbar(Lang.Coke.cutting, 5000, 'uncuff') then cuttingcoke = nil return end
end
2024-11-11 20:22:48 -08:00
TriggerServerEvent("md-drugs:server:cutcokeone", data.data)
2024-01-13 22:23:17 -08:00
cuttingcoke = nil
end)
2024-11-11 20:22:48 -08:00
RegisterNetEvent("md-drugs:client:bagcoke", function(data)
2024-05-02 18:34:14 -07:00
if not ItemCheck('empty_weed_bag') then return end
2024-01-13 22:23:17 -08:00
baggingcoke = true
2024-05-02 18:34:14 -07:00
if Config.FancyCokeAnims then
BagCoke()
else
if not progressbar(Lang.Coke.bagging, 5000, 'uncuff') then baggingcoke = nil return end
end
2024-11-11 20:22:48 -08:00
TriggerServerEvent("md-drugs:server:bagcoke", data.data)
2024-01-13 22:23:17 -08:00
baggingcoke = nil
end)
CreateThread(function()
2024-11-11 20:22:48 -08:00
local config = lib.callback.await('md-drugs:server:getLocs', false)
2024-05-02 18:34:14 -07:00
if Config.FancyCokeAnims == false then
2024-11-11 20:22:48 -08:00
AddBoxZoneMulti('cuttcoke', config.CuttingCoke, { type = "client",event = "md-drugs:client:cutcokeone", icon = "fa-solid fa-mortar-pestle", label = Lang.targets.coke.cut})
AddBoxZoneMulti('baggcoke', config.BaggingCoke, { type = "client",event = "md-drugs:client:bagcoke", icon = "fa-solid fa-sack-xmark", label = Lang.targets.coke.bag})
else
2024-11-11 20:22:48 -08:00
AddBoxZoneSingle('cutcoke', config.singleSpot.cutcoke,
{ data = config.singleSpot.cutcoke, type = "client", event = "md-drugs:client:cutcokeone", icon = "fa-solid fa-mortar-pestle", label = Lang.targets.coke.cut, canInteract = function() if cuttingcoke == nil and baggingcoke == nil then return true end end })
AddBoxZoneSingle('bagcokepowder', config.singleSpot.bagcokepowder,
{ data = config.singleSpot.bagcokepowder, type = "client", event = "md-drugs:client:bagcoke", icon = "fa-solid fa-sack-xmark", label = Lang.targets.coke.bag, canInteract = function() if baggingcoke == nil and cuttingcoke == nil then return true end end })
2024-05-02 18:34:14 -07:00
end
2024-07-11 17:40:27 -07:00
end)