Files
md-drugs/server/mescaline.lua
T
Mustache Dom 3d144cae58 Added integration for Fivemerr
if you want to use the logs go to line 3 of server/functions.lua and turn to true, then inside of your server.cfg add this 

```
set fivemerrLogs "API_KEY"
```
obviously replace the API_KEY with your api key
2024-07-16 14:14:48 -07:00

64 lines
2.2 KiB
Lua

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)
Log('Cactus Respawned At ' .. Config.Mescaline[loc].location, 'mescaline')
end)
end
RegisterNetEvent("Mescaline:pickupCane")
AddEventHandler("Mescaline:pickupCane", function(loc)
local playerPed = GetPlayerPed(source)
if CheckDist(source, playerPed, Config.Mescaline[loc].location) then end
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)
AddItem('cactusbulb', 1)
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')
end
end)
RegisterNetEvent("md-drugs:server:drymescaline")
AddEventHandler("md-drugs:server:drymescaline", function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if RemoveItem("cactusbulb", 1) then
AddItem("driedmescaline", 1)
Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Dried Mescaline', 'mescaline')
else
Notifys(Lang.mescaline.nocactus, "error")
end
end)
QBCore.Functions.CreateUseableItem("driedmescaline", function(source, item)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.Functions.RemoveItem("driedmescaline", 1) then
TriggerClientEvent("md-drugs:client:takemescaline", src)
Log(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' Consumed Mescaline', 'consume')
end
end)