made makeMenu function, moved all stores from config to server/travellingmerchant.lua

This commit is contained in:
Mustache Dom committed 2024-10-24 19:45:39 -07:00
1 parent e9f722a140
commit dbed6b3c47
15 files changed
+239 -316

No files matched your search

+3 -45
View File
@@ -1,51 +1,9 @@
local QBCore = exports['qb-core']:GetCoreObject()
local isActive = false
RegisterNetEvent('md-drugs:client:opendealermenu', function()
local dealermenu = {}
local rep = GetRep()
print(rep.dealerrep)
if Config.StupidassNewQbItemName then
for k, v in pairs (QBConfig.ProductsStupidNameRewrite) do
if rep.dealerrep >= v.minrep then
dealermenu[#dealermenu + 1] = {
icon = GetImage(v.name),
title = GetLabel(v.name),
description = '$'..v.price,
event = "md-drugs:client:travellingmerchantox",
args = {
item = v.name,
cost = v.price,
amount = v.amount,
table = QBConfig.ProductsStupidNameRewrite,
num = k,
}
}
sorter(dealermenu, 'title')
end
end
else
for k, v in pairs (QBConfig.Products) do
if rep.dealerrep >= v.minrep then
dealermenu[#dealermenu + 1] = {
icon = GetImage(v.name),
title = GetLabel(v.name),
description = '$'..v.price,
event = "md-drugs:client:travellingmerchantox",
args = {
item = v.name,
cost = v.price,
amount = v.amount,
table = QBConfig.Products,
num = k,
}
}
sorter(dealermenu, 'title')
end
end
end
lib.registerContext({id = 'dealermenu',title = "Dealer Menu", options = dealermenu})
RegisterNetEvent('md-drugs:client:opendealermenu', function()
local rep = GetRep()
makeMenu('dealermenu', rep)
lib.showContext('dealermenu')
end)
+30
View File
@@ -218,6 +218,36 @@ function sorter(sorting, value)
table.sort(sorting, function(a, b) print(a[value], b[value]) return a[value] < b[value] end)
end
function makeMenu(name, rep)
local menu = {}
local data = lib.callback.await('md-drugs:server:menu', false, name)
for k, v in pairs (data.table) do
local allow = false
if rep == nil then
allow = true
else
if rep.dealerrep >= v.minrep then allow = true end
end
if allow then
menu[#menu + 1] = {
icon = GetImage(v.name),
description = '$'.. v.price,
title = GetLabel(v.name),
onSelect = function()
local settext = "Cost: $"..v.price
local dialog = exports.ox_lib:inputDialog(v.name .."!", {
{ type = 'select', label = "Payment Type", default = "cash", options = { { value = "cash"}, { value = "bank"},}},
{ type = 'number', label = "Amount to buy", description = settext, min = 0, max = v.amount, default = 1 },
})
if not dialog[1] then return end
TriggerServerEvent("md-drugs:server:purchaseGoods", dialog[2], dialog[1], v.name, v.price, data.table, k)
end,
}
end
end
sorter(menu, 'title')
lib.registerContext({id = data.id, title = data.title, options = menu})
end
function ItemCheck(item)
+4 -4
View File
@@ -1,9 +1,9 @@
local QBCore = exports['qb-core']:GetCoreObject()
local icon = "fas fa-sign-in-alt"
local icon = "fa solid fa-eye"
CreateThread(function()
AddBoxZoneSingle('telecokein', Config.CokeTeleIn, {action = function()tele(Config.CokeTeleOut)end, icon = icon, label = Lang.targets.coke.enter}) -- coke
AddBoxZoneSingle('telecokeout', Config.CokeTeleOut, {action = function()tele(Config.CokeTeleIn) end, icon = icon, label = Lang.targets.coke.exits}) -- coke
AddBoxZoneMulti('makepowder', Config.MakePowder, {event = "md-drugs:client:makepowder", icon = icon, label = Lang.targets.coke.chop}) -- coke
AddBoxZoneSingle('telecokein', Config.CokeTeleIn, {action = function()tele(Config.CokeTeleOut)end, icon = 'fa-solid fa-door-open', label = Lang.targets.coke.enter}) -- coke
AddBoxZoneSingle('telecokeout', Config.CokeTeleOut, {action = function()tele(Config.CokeTeleIn) end, icon = "fa-solid fa-door-closed", label = Lang.targets.coke.exit}) -- coke
AddBoxZoneMulti('makepowder', Config.MakePowder, {event = "md-drugs:client:makepowder", icon = "fa-solid fa-scissors", label = Lang.targets.coke.chop}) -- coke
AddBoxZoneMulti('steallysergic', Config.lysergicacid, {event = "md-drugs:client:getlysergic", icon = icon, label = Lang.targets.lsd.lys}) -- lsd
AddBoxZoneMulti('stealdiethylamide', Config.diethylamide, {event = "md-drugs:client:getdiethylamide", icon = icon, label = Lang.targets.lsd.die}) -- lsd
AddBoxZoneMulti('gettabs', Config.gettabs, {event = "md-drugs:client:buytabs", icon = icon, label = Lang.targets.lsd.buyt}) -- lsd
+3 -40
View File
@@ -7,46 +7,9 @@ local current = "g_m_y_famdnf_01"
local CurrentLocation = Config.Travellingmerchant[num]
local travellingmerchant = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false)
Freeze(travellingmerchant, true, CurrentLocation.w)
AddSingleModel(travellingmerchant, { label = "Travelling Merchant", icon = "fas fa-eye",
AddSingleModel(travellingmerchant, { label = "Travelling Merchant", icon = "fas fa-eye",
action = function()
local ShopMenu = {}
for k, v in pairs (Config.Items.items) do
ShopMenu[#ShopMenu + 1] = {
icon = GetImage(v.name),
description = '$'.. v.price,
title = GetLabel(v.name),
event = "md-drugs:client:travellingmerchantox",
args = {
item = v.name,
cost = v.price,
amount = v.amount,
table = Config.Items.items,
num = k
}
}
sorter(ShopMenu, 'title')
lib.registerContext({id = 'travellingmerchant',title = "Travelling Merchant", options = ShopMenu})
end
lib.showContext('travellingmerchant')
makeMenu('travellingMerchant')
lib.showContext('travellingMerchant')
end}, nil)
end)
RegisterNetEvent("md-drugs:client:travellingmerchantox", function(data)
local price = data.cost
local settext = "Amnt: "..data.amount.." | Cost: "..price or "Cost: "..price
local max = data.amount
local dialog = exports.ox_lib:inputDialog(data.item .."!", {
{ type = 'select', label = "Payment Type", default = "cash",
options = {
{ value = "cash"},
{ value = "bank"},
}
},
{ type = 'number', label = "Amount to buy", description = settext, min = 0, max = max, default = 1 },
})
if not dialog[1] then return end
if data.cost == "Free" then data.cost = 0 end
TriggerServerEvent("md-drugs:server:travellingmerchantox", dialog[2], dialog[1], data.item, data.cost, data.table, data.num )
end)
+2 -22
View File
@@ -191,32 +191,12 @@ AlienEffect()
end)
CreateThread(function()
local WeedShop = {}
local current = "u_m_m_jesus_01"
local current = "u_m_m_jesus_01"
lib.requestModel(current, Config.RequestModelTime)
local CurrentLocation = Config.WeedSaleman
local WeedGuy = CreatePed(0,current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false)
Freeze(WeedGuy, true, CurrentLocation.w)
AddSingleModel(WeedGuy, {label = "Weed Shop",icon = "fas fa-eye",action = function() lib.showContext('WeedShop')end}, nil)
for k, v in pairs (Config.Weed.items) do
WeedShop[#WeedShop + 1] = {
icon = GetImage(v.name),
title = GetLabel(v.name),
description = '$'.. v.price,
event = "md-drugs:client:travellingmerchantox",
args = {
item = v.name,
cost = v.price,
amount = v.amount,
table = Config.Weed.items,
num = k,
}
}
sorter(WeedShop, 'title')
lib.registerContext({id = 'WeedShop',title = "Weed Shop", options = WeedShop})
end
AddSingleModel(WeedGuy, {label = "Weed Shop",icon = "fas fa-eye", action = function() makeMenu('WeedShop') lib.showContext('WeedShop')end}, nil)
end)
local function createBluntOptions(contextId, contextTitle, eventLabelPrefix, tableName)