Files
md-drugs/client/cocaine.lua
T

104 lines
4.2 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-23 17:49:03 -07:00
AddSingleModel(CocaPlant[loc], {icon = 'fas fa-hand', 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)
if not HasModelLoaded(hash) then LoadModel(hash) end
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-23 17:49:03 -07:00
AddSingleModel(CocaPlant[k], {icon = 'fas fa-hand', 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('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
LoadModel('prop_plant_01a')
TriggerEvent('coke:init')
end
end)
2024-10-23 17:49:03 -07:00
2024-01-13 22:23:17 -08:00
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('prop_plant_01a')
TriggerEvent('coke:init')
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-05-02 18:34:14 -07:00
RegisterNetEvent("md-drugs:client:cutcokeone", function()
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-01-13 22:23:17 -08:00
TriggerServerEvent("md-drugs:server:cutcokeone")
cuttingcoke = nil
end)
2024-05-02 18:34:14 -07:00
RegisterNetEvent("md-drugs:client:bagcoke", function()
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-01-13 22:23:17 -08:00
TriggerServerEvent("md-drugs:server:bagcoke")
baggingcoke = nil
end)
CreateThread(function()
2024-05-02 18:34:14 -07:00
if Config.FancyCokeAnims == false then
2024-10-23 16:04:09 -07:00
AddBoxZoneMulti('cuttcoke', Config.CuttingCoke, { type = "client", event = "md-drugs:client:cutcokeone", icon = "fas fa-sign-in-alt", label = Lang.targets.coke.cut})
AddBoxZoneMulti('baggcoke', Config.BaggingCoke, { type = "client", event = "md-drugs:client:bagcoke", icon = "fas fa-sign-in-alt", label = Lang.targets.coke.bag})
else
AddBoxZoneSingle('cutcoke', vector3(1093.17, -3195.74, -39.19),
2024-10-23 16:04:09 -07:00
{ type = "client", event = "md-drugs:client:cutcokeone", icon = "fas fa-sign-in-alt", label = Lang.targets.coke.cut, canInteract = function()if cuttingcoke == nil and baggingcoke == nil then return true end end })
AddBoxZoneSingle('bagcokepowder', vector3(1090.29, -3195.66, -39.13),
2024-10-23 16:04:09 -07:00
{ type = "client", event = "md-drugs:client:bagcoke", icon = "fas fa-sign-in-alt", 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)