Files
md-drugs/client/xtc.lua
T

215 lines
8.8 KiB
Lua
Raw Normal View History

local xtcpress = false
2026-01-30 00:45:03 -07:00
repeat Wait(100) until GlobalState.MDDrugsLocations.XTC ~= nil
2026-01-21 01:36:38 -07:00
local locations = GlobalState.MDDrugsLocations.XTC
2024-01-13 22:23:17 -08:00
2026-01-21 01:36:38 -07:00
local function getRecipeList(tbl, type)
local rec
if type == 'presses' then
rec = {'XTC FROM THE PREVIOUS TIER REQUIRED TO UPGRADE \n '}
else
rec = {'REQUIRED INGREDIENTS: \n '}
end
for m, d in pairs(tbl) do table.insert(rec, Bridge.Inventory.GetItemInfo(m).label .. ' X ' .. d .. ' \n ') end
return table.concat(rec, ' ')
2025-08-06 02:25:06 -06:00
end
2026-01-21 01:36:38 -07:00
Bridge.Callback.Register('md-drugs:client:setpress', function(xtcData)
2025-08-06 02:25:06 -06:00
if xtcpress then
2026-01-16 02:57:26 -07:00
Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.alreadyOut'), 'error')
2025-08-06 02:25:06 -06:00
return
2024-05-02 18:34:14 -07:00
end
2024-11-25 19:57:26 -08:00
local coords, head = StartRay2()
xtcpress = true
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.settingDown')) then return end
2025-08-06 02:25:06 -06:00
local press = CreateObject("bkr_prop_coke_press_01aa", coords.x, coords.y, coords.z, true, false, false)
PlaceObjectOnGroundProperly(press)
2024-11-25 19:57:26 -08:00
Freeze(press, true, head)
2025-08-06 02:25:06 -06:00
local options = {
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.pressIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.targetMake'),
2025-08-06 02:25:06 -06:00
distance = 2.0,
action = function()
local options = {}
for k, v in pairs(xtcData.recipes) do
local descript = getRecipeList(v.take)
2026-01-21 01:36:38 -07:00
local itemInfo = Bridge.Inventory.GetItemInfo(k)
2025-08-06 02:25:06 -06:00
options[#options + 1] = {
2026-01-21 01:36:38 -07:00
icon = itemInfo.image,
title = Bridge.Language.Locale(k),
2025-08-06 02:25:06 -06:00
description = descript,
2026-01-21 01:36:38 -07:00
onSelect = function()
2026-01-23 03:41:19 -07:00
if not minigame() then return end
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.making', Bridge.Language.Locale(k))) then return end
2025-08-06 02:25:06 -06:00
TriggerServerEvent("md-drugs:server:makextc", k)
end,
distance = 2.0
}
end
2026-01-21 01:36:38 -07:00
Bridge.Menu.Open({
id = 'XTC Recipes',
title = 'XTC Recipes',
options = options
})
2025-08-06 02:25:06 -06:00
end,
canInteract = function()
if xtcpress then return true end
end
},
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.pressIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.targetPickup'),
2025-08-06 02:25:06 -06:00
action = function()
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.picking')) then return end
2025-08-06 02:25:06 -06:00
DeleteObject(press)
xtcpress = false
TriggerServerEvent("md-drugs:server:getpressback")
end,
canInteract = function()
if xtcpress then return true end
end
},
}
2026-01-18 01:20:44 -07:00
Bridge.Target.AddLocalEntity(press, options)
2025-09-11 21:41:40 -06:00
return coords
2024-11-22 01:35:25 -08:00
end)
2025-08-06 02:25:06 -06:00
for k, v in pairs(locations.mdp2p) do
2026-01-30 00:45:03 -07:00
Bridge.Target.AddBoxZone('mdp2p'..k, v.loc, v.size, v.rot or 180.0, {
2025-08-06 02:25:06 -06:00
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.mdp2pIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.targetStealMDP2P'),
2025-08-06 02:25:06 -06:00
action = function()
2026-01-23 03:41:19 -07:00
if not minigame() then return end
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.stealingMDP2P')) then return end
2025-08-06 02:25:06 -06:00
TriggerServerEvent("md-drugs:server:stealmdp2p", k)
2025-08-09 03:10:00 -06:00
end,
canInteract = function()
return handleGang(v.gang)
2025-08-06 02:25:06 -06:00
end
2024-05-02 18:34:14 -07:00
}
2025-08-06 02:25:06 -06:00
})
end
for k, v in pairs(locations.isosafrole) do
2026-01-30 00:45:03 -07:00
Bridge.Target.AddBoxZone('isosafrole'..k, v.loc, v.size, v.rot or 180.0, {
2025-08-06 02:25:06 -06:00
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.isosafroleIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.targetStealIsosafrole'),
2025-08-06 02:25:06 -06:00
action = function()
2026-01-23 03:41:19 -07:00
if not minigame() then return end
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.stealingIsosafrole')) then return end
2025-08-06 02:25:06 -06:00
TriggerServerEvent("md-drugs:server:stealisosafrole", k)
2025-08-09 03:10:00 -06:00
end,
canInteract = function()
return handleGang(v.gang)
2025-08-06 02:25:06 -06:00
end
}
})
end
2024-01-13 22:23:17 -08:00
2025-08-06 02:25:06 -06:00
for k, v in pairs(locations.rawxtcloc) do
2026-01-30 00:45:03 -07:00
Bridge.Target.AddBoxZone('xtcraw'..k, v.loc, v.size, v.rot or 180.0, {
2025-08-06 02:25:06 -06:00
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.rawIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.targetRaw'),
2025-08-06 02:25:06 -06:00
action = function()
2026-01-23 03:41:19 -07:00
if not minigame() then return end
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.makingRaw')) then return end
2025-08-06 02:25:06 -06:00
TriggerServerEvent("md-drugs:server:makingrawxtc", k)
2025-08-09 03:10:00 -06:00
end,
canInteract = function()
return handleGang(v.gang)
2025-08-06 02:25:06 -06:00
end
}
})
end
2024-01-13 22:23:17 -08:00
2025-08-06 02:25:06 -06:00
for k, v in pairs(locations.xtcpress) do
2026-01-18 01:20:44 -07:00
requestModel(v.ped)
2025-08-06 02:25:06 -06:00
local ped = CreatePed(0, v.ped, v.loc, false, false)
Freeze(ped, true, v.loc.w)
2026-01-18 01:20:44 -07:00
Bridge.Target.AddLocalEntity(ped, {
2025-08-06 02:25:06 -06:00
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.pressIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.getPress'),
2026-01-21 01:36:38 -07:00
onSelect = function()
2025-08-06 02:25:06 -06:00
local options = {}
2026-01-21 01:36:38 -07:00
local recipeList = GlobalState.MDDrugsRecipes.XTC.presses
2025-08-06 02:25:06 -06:00
for m, d in pairs(recipeList) do
if m == 'singlepress' then
2026-01-21 01:36:38 -07:00
local itemInfo = Bridge.Inventory.GetItemInfo(m)
2025-08-06 02:25:06 -06:00
options[#options + 1] = {
2026-01-21 01:36:38 -07:00
icon = itemInfo.image,
title = itemInfo.label,
2026-01-16 02:57:26 -07:00
description = Bridge.Language.Locale('xtc.buySingle', d.cash),
2026-01-07 02:12:06 -07:00
type = d.type,
2026-01-21 01:36:38 -07:00
onSelect = function()
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.buyp')) then return end
TriggerServerEvent('md-drugs:server:buypress',k, m)
2025-08-06 02:25:06 -06:00
end,
}
else
2026-01-21 01:36:38 -07:00
local itemInfo = Bridge.Inventory.GetItemInfo(m)
local descript = getRecipeList(d.take, 'presses')
2025-08-06 02:25:06 -06:00
options[#options + 1] = {
2026-01-21 01:36:38 -07:00
icon = itemInfo.image,
title = itemInfo.label,
2025-08-06 02:25:06 -06:00
description = descript,
2026-01-07 02:12:06 -07:00
type = d.type,
2026-01-21 01:36:38 -07:00
onSelect = function()
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.buyp')) then return end
2025-08-06 02:25:06 -06:00
TriggerServerEvent("md-drugs:server:upgradepress", k, m)
end,
distance = 2.0
}
end
end
2026-01-07 02:12:06 -07:00
table.sort(options, function(a, b) return a.type < b.type end)
2026-01-21 01:36:38 -07:00
Bridge.Menu.Open({
id = 'XTC Presses',
title = 'XTC Presses',
options = options
})
2025-08-09 03:10:00 -06:00
end,
canInteract = function() return handleGang(v.gang) end
2025-08-06 02:25:06 -06:00
}
2024-01-13 22:23:17 -08:00
})
2025-08-06 02:25:06 -06:00
end
2024-01-13 22:23:17 -08:00
2025-08-06 02:25:06 -06:00
for k, v in pairs (locations.stamp) do
2026-01-30 00:45:03 -07:00
Bridge.Target.AddBoxZone('xtcstamp'..k, v.loc, v.size, v.rot or 180.0, {
2025-08-06 02:25:06 -06:00
{
2026-01-23 03:41:19 -07:00
icon = Bridge.Language.Locale('xtc.stampIcon'),
2026-01-16 02:57:26 -07:00
label = Bridge.Language.Locale('xtc.targetStamp'),
2026-01-21 01:36:38 -07:00
onSelect = function()
2025-08-06 02:25:06 -06:00
local item = {
2026-01-21 01:36:38 -07:00
{item = 'white_xtc', label = Bridge.Inventory.GetItemInfo('white_xtc').label, color = 'white'},
{item = 'red_xtc', label = Bridge.Inventory.GetItemInfo('red_xtc').label, color = 'red'},
{item = 'orange_xtc', label = Bridge.Inventory.GetItemInfo('orange_xtc').label, color = 'orange'},
{item = 'blue_xtc', label = Bridge.Inventory.GetItemInfo('blue_xtc').label, color = 'blue'},
2025-08-06 02:25:06 -06:00
}
local options = {}
for m, d in pairs (item) do
options[#options + 1] = {
2026-01-21 01:36:38 -07:00
icon = Bridge.Inventory.GetItemInfo(d.item).image,
2025-08-06 02:25:06 -06:00
title = d.label,
2026-01-16 02:57:26 -07:00
description = Bridge.Language.Locale('xtc.stamp_desc', d.color),
2025-08-06 02:25:06 -06:00
action = function()
2026-01-23 03:41:19 -07:00
if not minigame() then return end
2026-01-21 21:27:08 -07:00
if not progressbar(Bridge.Language.Locale('xtc.stamping', d.label)) then return end
2025-08-06 02:25:06 -06:00
TriggerServerEvent("md-drugs:server:stamp", k, d.color)
end,
distance = 2.0
}
end
2026-01-21 01:36:38 -07:00
Bridge.Menu.Open({
id = 'XTC Stamp',
title = 'XTC Stamp',
options = options
})
2025-08-09 03:10:00 -06:00
end,
canInteract = function() return handleGang(v.gang) end
2025-08-06 02:25:06 -06:00
}
})
end