Files
md-drugs/client/travellingmerchant.lua
T

62 lines
2.2 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)
2024-01-13 22:23:17 -08:00
local CurrentLocation = Config.Travellingmerchant[math.random(#Config.Travellingmerchant)]
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-01-13 22:23:17 -08:00
FreezeEntityPosition(travellingmerchant, true)
SetEntityInvincible(travellingmerchant, true)
2024-05-02 18:34:14 -07:00
if Config.oxtarget then
local options = {
{ label = "Travelling Merchant", icon = "fas fa-eye", onSelect = function() lib.showContext('travellingmerchant') end},
}
exports.ox_target:addLocalEntity(travellingmerchant, options)
2024-01-13 22:23:17 -08:00
else
2024-05-02 18:34:14 -07:00
exports['qb-target']:AddTargetEntity(travellingmerchant, {
2024-01-13 22:23:17 -08:00
options = {
2024-05-02 18:34:14 -07:00
{ label = "Travelling Merchant", icon = "fas fa-eye", action = function() lib.showContext('travellingmerchant') end},
}
})
2024-01-13 22:23:17 -08:00
end
end)
CreateThread(function()
2024-05-02 18:34:14 -07:00
local ShopMenu = {}
2024-01-13 22:23:17 -08:00
2024-05-02 18:34:14 -07:00
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,
title = QBCore.Shared.Items[v.name].label,
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-01-13 22:23:17 -08:00
end)
RegisterNetEvent("md-drugs:client:travellingmerchantox", function(data) local dialog
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 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)