Files
md-drugs/client/travellingmerchant.lua
T

51 lines
1.9 KiB
Lua
Raw Normal View History

2024-01-13 22:23:17 -08:00
local QBCore = exports['qb-core']:GetCoreObject()
CreateThread(function()
local current = "g_m_y_famdnf_01"
2024-05-02 18:34:14 -07:00
lib.requestModel(current, Config.RequestModelTime)
local num = lib.callback.await('md-drugs:server:GetMerchant', false)
local CurrentLocation = Config.Travellingmerchant[num]
2024-05-02 18:34:14 -07:00
local travellingmerchant = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false)
2024-07-11 17:39:58 -07:00
Freeze(travellingmerchant, true, CurrentLocation.w)
AddSingleModel(travellingmerchant, { label = "Travelling Merchant", icon = "fas fa-eye", action = function() lib.showContext('travellingmerchant') end}, nil)
2024-01-13 22:23:17 -08:00
end)
CreateThread(function()
2024-05-02 18:34:14 -07:00
local ShopMenu = {}
for k, v in pairs (Config.Items.items) do
ShopMenu[#ShopMenu + 1] = {
2024-05-18 13:38:24 -07:00
icon = GetImage(v.name),
2024-05-02 18:34:14 -07:00
description = '$'.. v.price,
2024-07-06 15:23:25 -07:00
title = GetLabel(v.name),
2024-05-02 18:34:14 -07:00
event = "md-drugs:client:travellingmerchantox",
args = {
item = v.name,
cost = v.price,
amount = v.amount,
table = Config.Items.items,
num = k
2024-01-13 22:23:17 -08:00
}
2024-05-02 18:34:14 -07:00
}
lib.registerContext({id = 'travellingmerchant',title = "Travelling Merchant", options = ShopMenu})
end
2024-10-23 17:44:46 -07:00
sorter(ShopMenu, 'title')
2024-01-13 22:23:17 -08:00
end)
RegisterNetEvent("md-drugs:client:travellingmerchantox", function(data)
2024-01-13 22:23:17 -08:00
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 },
})
2024-10-23 17:44:46 -07:00
if not dialog[1] then return end
2024-01-13 22:23:17 -08:00
if data.cost == "Free" then data.cost = 0 end
2024-05-02 18:34:14 -07:00
TriggerServerEvent("md-drugs:server:travellingmerchantox", dialog[2], dialog[1], data.item, data.cost, data.table, data.num )
2024-01-13 22:23:17 -08:00
end)