Files
md-drugs/server/crack.lua
T

82 lines
2.7 KiB
Lua
Raw Normal View History

2023-12-07 15:45:48 -08:00
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:makecrackone', function(num)
2024-10-24 20:19:44 -07:00
local src = source
2025-07-01 03:09:46 -07:00
local tier = 'tier1'
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.makecrack[num].loc, 2.0) then
ps.notify(src, 'You are not in the correct location', 'error')
return
end
2024-10-24 20:19:44 -07:00
if Config.TierSystem then
local crackTiers = {
2025-07-01 03:09:46 -07:00
{item = 'loosecoke', tier = 'tier1'},
{item = 'loosecokestagetwo', tier = 'tier2'},
{item = 'loosecokestagethree', tier = 'tier3'}
2024-10-24 20:19:44 -07:00
}
for _, v in ipairs(crackTiers) do
2025-07-01 03:09:46 -07:00
if ps.hasItem(src, v.item) then
tier = v.tier
break
2024-10-24 20:19:44 -07:00
end
end
end
2025-07-01 03:09:46 -07:00
if not GetRecipe(src, 'crack', 'cookcrack', tier) then return end
2023-12-07 15:45:48 -08:00
end)
2024-10-24 20:19:44 -07:00
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:bagcrack', function(num)
2024-10-24 20:19:44 -07:00
local src = source
2025-07-01 03:09:46 -07:00
local tier = 'tier1'
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.bagcrack[num].loc, 2.0) then
ps.notify(src, 'You are not in the correct location', 'error')
return
end
2024-10-24 20:19:44 -07:00
if Config.TierSystem then
local crackTiers = {
2025-07-01 03:09:46 -07:00
{item = 'crackrock', tier = 'tier1'},
{item = 'crackrockstagetwo', tier = 'tier2'},
{item = 'crackrockstagethree', tier = 'tier3'}
2024-10-24 20:19:44 -07:00
}
for _, v in ipairs(crackTiers) do
2025-07-01 03:09:46 -07:00
if ps.hasItem(src, v.item) then
tier = v.tier
break
2024-10-24 20:19:44 -07:00
end
end
end
2025-07-01 03:09:46 -07:00
if not GetRecipe(src, 'crack', 'bagcrack', tier) then return end
end)
local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3}
for k, v in pairs (cokecut) do
2025-07-01 03:09:46 -07:00
ps.createUseable(k, function(source, item)
local src = source
2025-07-01 03:09:46 -07:00
if ps.hasItem(src, item.name) then
if not ps.hasItem(src, 'bakingsoda', 1) then return end
local check = ps.callback('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further')
if not check then return end
2025-07-01 03:09:46 -07:00
if ps.removeItem(src, k, 1) and ps.removeItem(src, 'bakingsoda', 1) then
ps.addItem(src, 'crackrock', v)
end
end
end)
2024-10-30 13:03:51 -07:00
end
2025-07-01 03:09:46 -07:00
RegisterNetEvent("md-drugs:server:failcrackone", function(num)
local src = source
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.makecrack[num].loc, 2.0) then
ps.notify(src, 'You are not in the correct location', 'error')
return
end
local items = {
loosecoke = 1,
loosecokestagetwo = 1,
loosecokestagethree = 1
}
for k,v in pairs(items) do
if ps.hasItem(src, k, v) then
ps.removeItem(src, k, v)
ps.notify(src, 'You failed to make crack and lost '..v..' '..k, 'error')
return
end
end
end)