Files
md-drugs/client/plantSpawns.lua
T

113 lines
4.5 KiB
Lua
Raw Normal View History

2025-07-15 02:21:34 -07:00
local DrugPlants = {
2026-01-16 02:57:26 -07:00
{model = 'prop_plant_01a', label = 'coke', langs = Bridge.Language.Locale('coke.targetPick'), tbl = GlobalState.CocaPlant, plantTbl = {},
2025-07-15 02:21:34 -07:00
pick = function(loc)
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('coke.picking')) then return end
2025-07-15 02:21:34 -07:00
TriggerServerEvent("coke:pickupCane", loc)
return true
end,
2025-07-16 01:48:56 -07:00
allow = Config.Drugs.cocaine,
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('coke.pickIcon'),
2025-07-15 02:21:34 -07:00
},
2026-01-16 02:57:26 -07:00
{model = 'prop_plant_01b', label = 'heroin',langs = Bridge.Language.Locale('heroin.targetPick'), tbl = GlobalState.PoppyPlants, plantTbl = {},
2025-07-15 02:21:34 -07:00
pick = function(loc)
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('heroin.picking')) then return end
2025-07-15 02:21:34 -07:00
TriggerServerEvent("heroin:pickupCane", loc)
return true
end,
2025-07-15 02:23:03 -07:00
allow = Config.Drugs.heroin,
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('heroin.pickIcon'),
2025-07-15 02:21:34 -07:00
},
2026-01-16 02:57:26 -07:00
{model = 'prop_cactus_03', label = 'Mescaline', langs = Bridge.Language.Locale('mesc.targetPick'), tbl = GlobalState.Mescaline, plantTbl = {},
2025-07-15 02:21:34 -07:00
pick = function(loc)
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('mesc.picking')) then return end
2025-07-15 02:21:34 -07:00
TriggerServerEvent("Mescaline:pickupCane", loc)
return true
end,
2025-07-15 02:23:03 -07:00
allow = Config.Drugs.mescaline,
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('mesc.pickIcon'),
2025-07-15 02:23:03 -07:00
2025-07-15 02:21:34 -07:00
},
2026-01-16 02:57:26 -07:00
{model = 'prop_weed_01', label = 'weed', langs = Bridge.Language.Locale('weed.targetPick'), tbl = GlobalState.WeedPlant, plantTbl = {},
2025-07-15 02:21:34 -07:00
pick = function(loc)
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('weed.picking')) then return end
2025-07-15 02:21:34 -07:00
TriggerServerEvent("weed:pickupCane", loc)
return true
end,
2025-07-15 02:23:03 -07:00
allow = Config.Drugs.weed,
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('weed.pickIcon'),
2025-07-15 02:21:34 -07:00
},
2026-01-16 02:57:26 -07:00
{model = 'mushroom', label = 'shrooms', langs = Bridge.Language.Locale('shrooms.targetPick'), tbl = GlobalState.shrooms, plantTbl = {},
2025-07-15 02:21:34 -07:00
pick = function(loc)
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('shrooms.picking')) then return end
2025-07-15 02:21:34 -07:00
TriggerServerEvent("shrooms:pickupCane", loc)
return true
end,
2025-07-15 02:23:03 -07:00
allow = Config.Drugs.shrooms,
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('shrooms.pickIcon'),
2025-07-15 02:21:34 -07:00
},
}
for k, v in pairs (DrugPlants) do
2025-07-15 02:23:03 -07:00
if not v.allow then goto continue end
2025-07-15 02:21:34 -07:00
RegisterNetEvent(v.label ..':respawnCane', function(loc)
local plant = v.tbl[loc]
local hash = GetHashKey(plant.model)
if not v.plantTbl[loc] then
2026-01-18 01:20:44 -07:00
requestModel(hash)
2025-07-15 02:21:34 -07:00
v.plantTbl[loc] = CreateObject(hash, plant.location, false, true, true)
Freeze(v.plantTbl[loc], true, plant.heading)
2026-01-18 01:20:44 -07:00
Bridge.Target.AddLocalEntity(v.plantTbl[loc], {
2025-07-15 02:21:34 -07:00
{
icon = v.icon,
2025-08-06 02:25:06 -06:00
label = v.langs,
2025-07-15 02:21:34 -07:00
action = function()
if not v.pick(loc) then return end
end
}
})
2026-01-30 01:19:50 -07:00
targets[#targets+1] = v.plantTbl[loc]
2025-07-15 02:21:34 -07:00
end
end)
RegisterNetEvent(v.label ..':removeCane', function(loc)
DeleteEntity(v.plantTbl[loc])
v.plantTbl[loc] = nil
end)
RegisterNetEvent(v.label ..":init", function()
if not v.plantTbl then v.plantTbl = {} end
for key, value in pairs (v.tbl) do
local hash = GetHashKey(value.model)
if not value.taken then
v.plantTbl[key] = CreateObject(hash, value.location.x, value.location.y, value.location.z, false, true, true)
Freeze(v.plantTbl[key], true, v.heading)
2026-01-18 01:20:44 -07:00
Bridge.Target.AddLocalEntity(v.plantTbl[key], {
2025-07-15 02:21:34 -07:00
{
icon = v.icon,
2025-08-06 02:25:06 -06:00
label = v.langs,
2025-07-15 02:21:34 -07:00
action = function()
if not v.pick(key) then return end
end
}
})
2026-01-30 01:19:50 -07:00
targets[#targets+1] = v.plantTbl[key]
2025-07-15 02:21:34 -07:00
end
end
end)
TriggerEvent(v.label ..":init")
2025-07-15 02:23:03 -07:00
::continue::
2025-07-15 02:21:34 -07:00
end
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01a'))
for k, v in pairs(DrugPlants) do
for key, plant in pairs(v.plantTbl) do
if DoesEntityExist(plant) then DeleteEntity(plant) end
v.plantTbl[key] = nil
end
end
end
end)