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 )
2024-07-16 14:14:48 -07:00
Log ( 'Cactus Respawned At ' .. Config.Mescaline [ loc ]. location , 'mescaline' )
2023-12-07 15:45:48 -08:00
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 )
2024-07-16 14:14:48 -07:00
Log ( Player.PlayerData . charinfo.firstname .. ' ' .. Player.PlayerData . charinfo.lastname .. ' Picked Cactus Bulbs With a distance of ' .. dist ( source , playerPed , Config.Mescaline [ loc ]. location ) .. ' vectors' , 'mescaline' )
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 )
2024-07-16 14:14:48 -07:00
Log ( Player.PlayerData . charinfo.firstname .. ' ' .. Player.PlayerData . charinfo.lastname .. ' Dried Mescaline' , 'mescaline' )
2024-05-02 18:34:49 -07:00
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 )
2024-07-16 14:14:48 -07:00
Log ( Player.PlayerData . charinfo.firstname .. ' ' .. Player.PlayerData . charinfo.lastname .. ' Consumed Mescaline' , 'consume' )
2024-05-02 18:34:49 -07:00
end
2024-01-08 23:55:31 -08:00
end )