Files
md-drugs/server/heroin.lua
T

239 lines
6.2 KiB
Lua
Raw Normal View History

2026-03-05 00:00:34 -08:00
if not Config.Drugs['heroin'] then return end
2025-07-15 02:21:34 -07:00
local heroinLabKits = {}
2023-12-07 15:45:48 -08:00
2026-01-16 02:57:26 -07:00
Bridge.Callback.Register('md-drugs:server:removeCleaningKitHeroin', function(source)
if heroinLabKits[source] then
return Bridge.Inventory.RemoveItem(source, 'cleaningkit', 1)
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)
2026-01-16 02:57:26 -07:00
local function getTier(source)
if not Config.TierSystem then
return 'tier1'
end
local heroin = tonumber(getRep(source, 'heroin'))
if heroin <= Config.Tier1 then
return 'tier1'
elseif heroin >= Config.Tier1 and heroin <= Config.Tier2 then
return'tier2'
else
return 'tier3'
end
end
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
if timeOut(src, 'md-drugs:server:dryplant') then return end
2026-01-16 02:57:26 -07:00
2026-01-31 02:05:15 -07:00
if not checkDistance(src, Config.Heroin.Locations.dryplant[num].loc, 3.0, 'md-drugs:server:dryplant') then
2025-08-09 03:10:00 -06:00
return
end
2026-01-16 02:57:26 -07:00
local tier = getTier(src)
2026-01-31 02:05:15 -07:00
if not craft(src, Config.Heroin.Recipes.dryheroin[tier]) then
2025-07-14 01:34:58 -07:00
return
2023-12-07 15:45:48 -08:00
end
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
if timeOut(src, 'md-drugs:server:cutheroin') then return end
2026-01-31 02:05:15 -07:00
if not checkDistance(src, Config.Heroin.Locations.cutheroinone[num].loc, 3.0, 'md-drugs:server:cutheroin') then
2025-08-09 03:10:00 -06:00
return
end
2026-01-16 02:57:26 -07:00
local tier = 'tier1'
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'
}
2026-01-16 02:57:26 -07:00
for item, tiers in pairs (itemList) do
if Bridge.Inventory.HasItem(src, item) then
tier = tiers
2026-01-22 02:08:35 -07:00
break
2025-07-14 01:34:58 -07:00
end
2023-12-07 15:45:48 -08:00
end
2026-01-16 02:57:26 -07:00
end
2026-01-31 02:05:15 -07:00
if not craft(src, Config.Heroin.Recipes.cutheroin[tier]) then
2026-01-16 02:57:26 -07:00
return
2023-12-07 15:45:48 -08:00
end
end)
2025-08-06 02:25:06 -06:00
RegisterServerEvent('md-drugs:server:getheroinlabkit', function(num)
2024-05-02 18:34:49 -07:00
local src = source
2026-01-16 02:57:26 -07:00
if timeOut(src, 'md-drugs:server:getheroinlabkit') then return end
2026-01-16 02:57:26 -07:00
2026-01-31 02:05:15 -07:00
if not checkDistance(src, Config.Heroin.Locations.buyKit[num].loc, 3.0, 'md-drugs:server:getheroinlabkit') then
2026-01-16 02:57:26 -07:00
return
end
local has = Bridge.Inventory.HasItem(src, 'heroinlabkit')
if has then
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.hasKitAlready'), 'error')
2025-08-09 03:10:00 -06:00
return
end
2026-01-31 02:05:15 -07:00
if Bridge.Framework.RemoveAccountBalance(src, 'cash', Config.Heroin.prices.heroinlabkitprice) then
2026-01-16 02:57:26 -07:00
Bridge.Inventory.AddItem(src, 'heroinlabkit', 1)
2024-05-02 18:34:49 -07:00
else
2026-01-31 02:05:15 -07:00
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.notEnoughMoney', Config.Heroin.prices.heroinlabkitprice), 'error')
2023-12-07 15:45:48 -08:00
end
end)
2026-01-16 02:57:26 -07:00
2024-11-22 12:26:27 -08:00
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
2026-01-16 02:57:26 -07:00
if not heroinLabKits[src] then
return
2023-12-07 15:45:48 -08:00
end
2026-01-16 02:57:26 -07:00
local loc = vector3(heroinLabKits[src].coords.x, heroinLabKits[src].coords.y, heroinLabKits[src].coords.z)
2026-01-19 00:46:49 -07:00
if not checkDistance(src, loc, 5.0, 'md-drugs:server:getheroinlabkitback') then
2026-01-16 02:57:26 -07:00
return
end
heroinLabKits[src] = nil
Bridge.Inventory.AddItem(src, 'heroinlabkit', 1)
2023-12-07 15:45:48 -08:00
end)
2024-11-22 12:26:27 -08:00
2026-01-16 02:57:26 -07:00
Bridge.Framework.RegisterUsableItem('heroinlabkit', function(source, item)
2024-11-22 12:26:27 -08:00
local src = source
2026-01-16 02:57:26 -07:00
if not Bridge.Inventory.HasItem(src, 'heroinlabkit', 1) then
return
end
if heroinLabKits[src] then
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.hasKitAlreadyPlaced'), "error")
return
end
local placed, loc = Bridge.Callback.Trigger('md-drugs:client:setheroinlabkit', src)
2025-08-06 02:25:06 -06:00
if placed then
2026-01-16 02:57:26 -07:00
if Bridge.Inventory.RemoveItem(src, 'heroinlabkit', 1) then
heroinLabKits[src] = {
2025-08-11 16:49:24 -06:00
src = src,
coords = loc,
2026-01-16 02:57:26 -07:00
}
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.placedKit'), "success")
2025-08-11 16:49:24 -06:00
end
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
if timeOut(src, 'md-drugs:server:heatliquidheroin') then return end
2026-01-16 02:57:26 -07:00
if not heroinLabKits[src] then
2026-01-22 02:08:35 -07:00
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.missedTable', Bridge.Framework.GetPlayerIdentifier(src), 'md-drugs:server:heatliquidheroin'), 'error')
2026-01-16 02:57:26 -07:00
return
end
2026-01-31 02:05:15 -07:00
if not checkDistance(src, heroinLabKits[src].coords, 3.0, 'md-drugs:server:heatliquidheroin') then
return
end
2026-01-16 02:57:26 -07:00
local tier = 'tier1'
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
2026-01-16 02:57:26 -07:00
if Bridge.Inventory.HasItem(src, k) then
tier = v
break
2025-07-14 01:34:58 -07:00
end
2023-12-07 15:45:48 -08:00
end
2026-01-16 02:57:26 -07:00
end
2026-01-31 02:05:15 -07:00
if not craft(src, Config.Heroin.Recipes.fillvial[tier]) then
2026-01-16 02:57:26 -07:00
return
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
2026-01-16 02:57:26 -07:00
if not heroinLabKits[src] then
2026-01-22 02:08:35 -07:00
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.missedTable', Bridge.Framework.GetPlayerIdentifier(src), 'md-drugs:server:failheatingheroin'), 'error')
2026-01-16 02:57:26 -07:00
end
2025-07-14 01:34:58 -07:00
local itemList = {
heroincut = 1,
heroincutstagetwo = 1,
heroincutstagethree = 1
}
2026-01-16 02:57:26 -07:00
2025-07-14 01:34:58 -07:00
for k, v in pairs(itemList) do
2026-01-16 02:57:26 -07:00
if Bridge.Inventory.RemoveItem(src, k, v) then
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.failed'), "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
if timeOut(src, 'md-drugs:server:fillneedle') then return end
2026-01-16 02:57:26 -07:00
2026-01-31 02:05:15 -07:00
if not checkDistance(src, Config.Heroin.Locations.fillneedle[num].loc, 3.0, 'md-drugs:server:fillneedle') then
2025-07-14 01:34:58 -07:00
return
end
2026-01-16 02:57:26 -07:00
local tier = 'tier1'
2023-12-07 15:45:48 -08:00
if Config.TierSystem then
2025-07-14 01:34:58 -07:00
local itemList = {
2026-01-16 02:57:26 -07:00
heroinvial = 'tier1',
heroinvialstagetwo = 'tier2',
heroinvialstagethree = 'tier3'
}
for item, tiers in pairs (itemList) do
if Bridge.Inventory.HasItem(src, item) then
tier = tiers
break
2025-07-14 01:34:58 -07:00
end
2023-12-07 15:45:48 -08:00
end
2026-01-16 02:57:26 -07:00
end
2026-01-31 02:05:15 -07:00
if not craft(src, Config.Hero8in.Recipes.fillneedle[tier]) then
2026-01-16 02:57:26 -07:00
return
2023-12-07 15:45:48 -08:00
end
end)
RegisterServerEvent('md-drugs:server:failheroin', function()
local src = source
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
2026-01-16 02:57:26 -07:00
if Bridge.Inventory.RemoveItem(src, k, v) then
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Heroin.failneedle'), "error")
2025-07-14 01:34:58 -07:00
return
end
2023-12-07 15:45:48 -08:00
end
else
2026-01-16 02:57:26 -07:00
Bridge.Inventory.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
2026-01-16 02:57:26 -07:00
if heroinLabKits[src] then
heroinLabKits[src] = nil
Bridge.Inventory.AddItem(src, 'heroinlabkit', 1)
2024-11-22 12:26:27 -08:00
end
2025-08-12 16:49:08 -05:00
end)