Files
md-drugs/server/weed.lua
T

107 lines
3.1 KiB
Lua
Raw Normal View History

2024-05-07 13:12:03 -07:00
2024-05-02 18:34:49 -07:00
local QBCore = exports['qb-core']:GetCoreObject()
2023-12-07 15:45:48 -08:00
GlobalState.WeedPlant = Config.WeedPlant
Citizen.CreateThread(function()
for _, v in pairs(Config.WeedPlant) do
v.taken = false
end
end)
function WeedCooldown(loc)
CreateThread(function()
Wait(Config.respawnTime * 1000)
Config.WeedPlant[loc].taken = false
GlobalState.WeedPlant = Config.WeedPlant
Wait(1000)
TriggerClientEvent('weed:respawnCane', -1, loc)
2024-07-16 14:14:48 -07:00
Log('Weed Plant Respawned At ' .. Config.WeedPlant[loc].location, 'weed')
2023-12-07 15:45:48 -08:00
end)
end
RegisterNetEvent("weed:pickupCane")
AddEventHandler("weed:pickupCane", function(loc)
local src = source
2023-12-07 15:45:48 -08:00
if not Config.WeedPlant[loc].taken then
Config.WeedPlant[loc].taken = true
GlobalState.WeedPlant = Config.WeedPlant
TriggerClientEvent("weed:removeCane", -1, loc)
WeedCooldown(loc)
AddItem(src, 'wetcannabis', 1)
Log(GetName(source) .. ' Picked Weed With a distance of ' .. dist(source, Config.WeedPlant[loc].location) .. ' vectors', 'weed')
2024-07-16 14:14:48 -07:00
2023-12-07 15:45:48 -08:00
end
end)
--------------- events
2023-12-07 15:45:48 -08:00
RegisterServerEvent('md-drugs:server:dryoutweed', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if RemoveItem(src,"wetcannabis", 1) then
AddItem(src,"drycannabis", 1)
Log(GetName(source) .. ' Dried Weed', 'weed')
2024-05-02 18:34:49 -07:00
else
Notifys(src, Lang.Weed.nodry, "error")
2024-05-07 13:12:03 -07:00
end
2023-12-07 15:45:48 -08:00
end)
local bluntwrap = {'mdreddextro','mdlean'}
for k, v in pairs (bluntwrap) do
QBCore.Functions.CreateUseableItem(v, function(source, item)
local src = source
TriggerClientEvent('md-drugs:client:makeBluntWrap', src)
end)
2024-05-07 13:12:03 -07:00
end
2023-12-07 15:45:48 -08:00
local bluntwraps = {'leanbluntwrap', 'dextrobluntwrap', 'bluntwrap'}
for k, v in pairs (bluntwraps) do
QBCore.Functions.CreateUseableItem(v, function(source, item)
local src = source
TriggerClientEvent('md-drugs:client:rollBlunt', source)
end)
2024-05-07 13:12:03 -07:00
end
2023-12-07 15:45:48 -08:00
2024-07-21 21:45:06 -07:00
RegisterServerEvent('md-drugs:server:MakeWeedItems', function(data)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
if not GetRecipe(src, data.recipe, data.table, data.item) then return end
2023-12-07 15:45:48 -08:00
end)
QBCore.Functions.CreateUseableItem("dabrig", function(source, item)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.Functions.GetItemByName("butanetorch") then
if RemoveItem(src, "shatter", 1) then
Notifys(src, 'test', 'success')
2023-12-07 22:10:05 -08:00
TriggerClientEvent("md-drugs:client:dodabs", src)
2023-12-07 22:29:01 -08:00
end
2023-12-07 15:45:48 -08:00
end
end)
2024-07-21 21:45:06 -07:00
2023-12-07 15:45:48 -08:00
QBCore.Functions.CreateUseableItem("weedgrinder", function(source, item)
local src = source
if RemoveItem(src, "drycannabis",1 ) then
AddItem(src, "grindedweed", 1)
2024-05-02 18:34:49 -07:00
TriggerClientEvent("md-drugs:client:grind", src)
2024-07-21 21:45:06 -07:00
else
Notifys(src,'You Need Dried Weed', 'error')
2023-12-07 15:45:48 -08:00
end
end)
QBCore.Functions.CreateUseableItem("mdwoods", function(source, item)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
2024-05-02 18:34:49 -07:00
TriggerClientEvent("md-drugs:client:rollanim", src)
Wait(4000)
if RemoveItem(src, "mdwoods",1 ) then
AddItem(src, "bluntwrap", 5)
AddItem(src, "tobacco", 5)
2023-12-07 15:45:48 -08:00
end
end)
2024-05-07 13:12:03 -07:00