Files
md-drugs/server/heroin.lua
T

207 lines
5.9 KiB
Lua
Raw Normal View History

2025-07-15 02:21:34 -07:00
local heroinLabKits = {}
2024-11-16 23:39:34 -08:00
local prices = {
heroinlabkitprice = 10000
}
2023-12-07 15:45:48 -08:00
2025-07-01 03:09:46 -07:00
ps.registerCallback('removeCleaningkit', function(source)
2024-12-16 03:22:44 -08:00
for k, v in pairs(heroinLabKits) do
2025-07-14 01:34:58 -07:00
if v.ownerid == ps.getIdentifier(source) then
ps.removeItem(source, 'cleaningkit', 1)
2024-12-16 03:22:44 -08:00
return true
end
2023-12-07 15:45:48 -08:00
end
2024-12-16 03:22:44 -08:00
return false
2023-12-07 15:45:48 -08:00
end)
2025-07-16 01:48:56 -07:00
2023-12-07 15:45:48 -08:00
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:dryplant', function(num)
2023-12-07 15:45:48 -08:00
local src = source
2025-07-14 01:34:58 -07:00
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.dryplant[num].loc, 3.0) then return end
if not ps.hasItem(src, 'poppyresin', 1) then return end
2023-12-07 15:45:48 -08:00
if Config.TierSystem then
local heroin = getRep(src, 'heroin')
2024-05-02 18:34:49 -07:00
if heroin <= Config.Tier1 then
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end
2024-05-02 18:34:49 -07:00
elseif heroin >= Config.Tier1 and heroin <= Config.Tier2 then
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier2') then return end
2023-12-07 15:45:48 -08:00
else
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier3') then return end
2023-12-07 15:45:48 -08:00
end
2025-07-14 01:34:58 -07:00
return
2023-12-07 15:45:48 -08:00
end
2025-07-14 01:34:58 -07:00
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end
2023-12-07 15:45:48 -08:00
end)
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:cutheroin', function(num)
2023-12-07 15:45:48 -08:00
local src = source
2025-07-14 01:34:58 -07:00
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.cutheroinone[num].loc, 3.0) then return end
if not ps.hasItem(src, 'bakingsoda', 1) then return end
2023-12-07 15:45:48 -08:00
if Config.TierSystem then
2025-07-14 01:34:58 -07:00
local itemList = {
heroin = 'tier1',
heroinstagetwo = 'tier2',
heroinstagethree = 'tier3'
}
for k, v in pairs(itemList) do
local cuth = ps.hasItem(src, k)
if cuth then
if not GetRecipe(src, 'heroin', 'cutheroin', v) then return end
AddRep(src, 'heroin')
return
end
2023-12-07 15:45:48 -08:00
end
else
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end
2023-12-07 15:45:48 -08:00
end
end)
RegisterServerEvent('md-drugs:server:getheroinlabkit', function()
2024-05-02 18:34:49 -07:00
local src = source
2025-07-14 01:34:58 -07:00
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.singleSpot.buyheroinlabkit, 3.0) then return end
local has = ps.hasItem(src, 'heroinlabkit')
if has then ps.notify(src, Lang.Heroin.haskit, 'error') return end
if ps.removeMoney(src, 'cash', prices.heroinlabkitprice) then
ps.addItem(src, 'heroinlabkit', 1)
2024-05-02 18:34:49 -07:00
else
2025-07-14 01:34:58 -07:00
ps.notify(src, 'You Need '.. prices.heroinlabkitprice .. ' In Cash For This', 'error')
2023-12-07 15:45:48 -08:00
end
end)
2024-11-22 12:26:27 -08:00
local function hasHKit(src)
for k, v in pairs(heroinLabKits) do
2025-07-14 01:34:58 -07:00
if v.ownerid == ps.getIdentifier(src) then
2024-11-22 12:26:27 -08:00
return true
end
end
return false
end
2023-12-07 15:45:48 -08:00
RegisterServerEvent('md-drugs:server:getheroinlabkitback', function()
2024-11-22 12:26:27 -08:00
local src = source
if not hasHKit(src) then return end
for k, v in pairs (heroinLabKits) do
2025-07-14 01:34:58 -07:00
if v.ownerid == ps.getIdentifier(src) then
2024-11-22 12:26:27 -08:00
table.remove(heroinLabKits, k)
2025-07-14 01:34:58 -07:00
ps.addItem(src, 'heroinlabkit', 1)
2024-11-22 12:26:27 -08:00
end
2023-12-07 15:45:48 -08:00
end
end)
2024-11-22 12:26:27 -08:00
2025-07-14 01:34:58 -07:00
ps.createUseable('heroinlabkit', function(source, item)
2024-11-22 12:26:27 -08:00
local src = source
2025-07-14 01:34:58 -07:00
if not ps.hasItem(src, 'heroinlabkit', 1) then return end
2025-07-01 03:09:46 -07:00
local placed, loc = ps.callback('md-drugs:client:setheroinlabkit', src)
2024-11-22 12:26:27 -08:00
if placed then
2025-07-14 01:34:58 -07:00
ps.removeItem(src, 'heroinlabkit', 1)
2024-11-22 12:26:27 -08:00
table.insert(heroinLabKits, {
2025-07-14 01:34:58 -07:00
src = src,
ownerid = ps.getIdentifier(src),
2024-11-22 12:26:27 -08:00
coords = loc,
2025-07-14 01:34:58 -07:00
name = ps.getPlayerName(src)
2024-11-22 12:26:27 -08:00
})
2025-07-15 02:21:34 -07:00
ps.notify(src, ps.lang('Heroin.placed'), "success")
2023-12-07 15:45:48 -08:00
end
end)
RegisterServerEvent('md-drugs:server:heatliquidheroin', function()
2025-07-14 01:34:58 -07:00
local src = source
2024-11-22 12:26:27 -08:00
if not hasHKit(src) then return end
2025-07-15 02:21:34 -07:00
if not ps.hasItem(src, 'emptyvial', 1) then return end
2023-12-07 15:45:48 -08:00
if Config.TierSystem then
2025-07-14 01:34:58 -07:00
local itemList = {
heroincut = 'tier1',
heroincutstagetwo = 'tier2',
heroincutstagethree = 'tier3'
}
for k, v in pairs(itemList) do
local cuth = ps.hasItem(src, k)
if cuth then
if not GetRecipe(src, 'heroin', 'fillvial', v) then return end
AddRep(src, 'heroin')
return
end
2023-12-07 15:45:48 -08:00
end
else
if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end
2023-12-07 15:45:48 -08:00
end
end)
RegisterServerEvent('md-drugs:server:failheatingheroin', function()
2025-07-14 01:34:58 -07:00
local src = source
if not hasHKit(src) then return end
local itemList = {
heroincut = 1,
heroincutstagetwo = 1,
heroincutstagethree = 1
}
for k, v in pairs(itemList) do
local cuth = ps.hasItem(src, k)
if cuth then
ps.removeItem(src, k, v)
2025-07-15 02:21:34 -07:00
ps.notify(src, ps.lang('Heroin.fail'), "error")
2025-07-14 01:34:58 -07:00
return
end
2023-12-07 15:45:48 -08:00
end
end)
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:fillneedle', function(num)
2023-12-07 15:45:48 -08:00
local src = source
2025-07-14 01:34:58 -07:00
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.fillneedle[num].loc, 3.0) then
2025-07-15 02:21:34 -07:00
ps.notify(src, ps.lang('Heroin.noloc'), 'error')
2025-07-14 01:34:58 -07:00
return
end
if not ps.hasItem(src, 'needle', 1) then return end
2023-12-07 15:45:48 -08:00
if Config.TierSystem then
2025-07-14 01:34:58 -07:00
local itemList = {
{item = 'heroinvial', tier = 'tier1', log = ' Filled Heroin Needle'},
{item = 'heroinvialstagetwo', tier = 'tier2', log = ' Filled Heroin Needle tier 2'},
{item = 'heroinvialstagethree', tier = 'tier3', log = ' Filled Heroin Needle tier 3'}
}
for k, v in pairs(itemList) do
local vh = ps.hasItem(src, v.item)
if vh then
if not GetRecipe(src, 'heroin', 'fillneedle', v.tier) then return end
AddRep(src, 'heroin')
Log(ps.getPlayerName(src) .. v.log, 'heroin')
return
end
2023-12-07 15:45:48 -08:00
end
2025-07-14 01:34:58 -07:00
ps.notify(src,Lang.Heroin.nofill, "error")
2023-12-07 15:45:48 -08:00
else
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end
2023-12-07 15:45:48 -08:00
end
end)
RegisterServerEvent('md-drugs:server:failheroin', function()
local src = source
2025-07-14 01:34:58 -07:00
Log(ps.getPlayerName(src) ..' Sucks And Burned Their Heroin', 'heroin')
2023-12-07 15:45:48 -08:00
if Config.TierSystem then
2025-07-14 01:34:58 -07:00
local itemList = {
heroinvial = 1,
heroinvialstagetwo = 1,
heroinvialstagethree = 1
}
for k, v in pairs (itemList) do
local cuth = ps.hasItem(src, k)
if cuth then
ps.removeItem(src, k, v)
2025-07-15 02:21:34 -07:00
ps.notify(src, ps.lang('Heroin.failneedle'), "error")
2025-07-14 01:34:58 -07:00
return
end
2023-12-07 15:45:48 -08:00
end
else
2025-07-14 01:34:58 -07:00
ps.removeItem(src, 'heroinvial', 1)
2023-12-07 15:45:48 -08:00
end
end)
2024-11-22 12:26:27 -08:00
AddEventHandler('playerDropped', function()
local src = source
for k, v in pairs(heroinLabKits) do
if v.src == src then
table.remove(heroinLabKits, k)
2025-07-14 01:34:58 -07:00
ps.addItem(src, 'heroinlabkit', 1)
2024-11-22 12:26:27 -08:00
end
end
end)