Files
md-drugs/server/mescaline.lua
T

59 lines
1.7 KiB
Lua
Raw Normal View History

2023-12-07 15:45:48 -08:00
local QBCore = exports['qb-core']:GetCoreObject()
GlobalState.Mescaline = Config.Mescaline
Citizen.CreateThread(function()
for _, v in pairs(Config.Mescaline) do
v.taken = false
end
end)
function MescalineCooldown(loc)
CreateThread(function()
Wait(Config.respawnTime * 1000)
Config.Mescaline[loc].taken = false
GlobalState.Mescaline = Config.Mescaline
Wait(1000)
TriggerClientEvent('Mescaline:respawnCane', -1, loc)
end)
end
RegisterNetEvent("Mescaline:pickupCane")
AddEventHandler("Mescaline:pickupCane", function(loc)
2024-05-02 18:34:49 -07:00
local playerPed = GetPlayerPed(source)
if CheckDist(source, playerPed, Config.Mescaline[loc].location) then end
2023-12-07 15:45:48 -08:00
if not Config.Mescaline[loc].taken then
Config.Mescaline[loc].taken = true
GlobalState.Mescaline = Config.Mescaline
TriggerClientEvent("Mescaline:removeCane", -1, loc)
MescalineCooldown(loc)
local Player = QBCore.Functions.GetPlayer(source)
2024-05-02 18:34:49 -07:00
AddItem('cactusbulb', 1)
2023-12-07 15:45:48 -08:00
end
end)
RegisterNetEvent("md-drugs:server:drymescaline")
AddEventHandler("md-drugs:server:drymescaline", function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
2024-05-02 18:34:49 -07:00
if RemoveItem("cactusbulb", 1) then
AddItem("driedmescaline", 1)
else
Notifys(Lang.mescaline.nocactus, "error")
end
2023-12-07 15:45:48 -08:00
end)
QBCore.Functions.CreateUseableItem("driedmescaline", function(source, item)
2024-05-02 18:34:49 -07:00
local src = source
local Player = QBCore.Functions.GetPlayer(src)
2023-12-07 15:45:48 -08:00
2024-05-02 18:34:49 -07:00
if Player.Functions.RemoveItem("driedmescaline", 1) then
TriggerClientEvent("md-drugs:client:takemescaline", src)
end
2024-01-08 23:55:31 -08:00
end)