It is better to transfer the code to a script qb-shop
Reproduction
The script should be somewhat independent
Actually, it is the correct place in the qb-shop script
Not in qb-inv
Expected behavior
There will be more customization and the code will not be so large as to be distracting
---Gets the closest vending machine object to the client
---@return integer closestVendingMachine
local function GetClosestVending()
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local object = nil
for _, machine in pairs(Config.VendingObjects) do
local ClosestObject = GetClosestObjectOfType(pos.x, pos.y, pos.z, 0.75, joaat(machine), false, false, false)
if ClosestObject ~= 0 then
if object == nil then
object = ClosestObject
end
end
end
return object
end
---Opens the vending machine shop
local function OpenVending()
local ShopItems = {}
ShopItems.label = 'Vending Machine'
ShopItems.items = Config.VendingItem
ShopItems.slots = #Config.VendingItem
TriggerServerEvent('inventory:server:OpenInventory', 'shop', 'Vendingshop_' .. math.random(1, 99), ShopItems)
end
Summary
It is better to transfer the code to a script qb-shop
Reproduction
The script should be somewhat independent
Actually, it is the correct place in the qb-shop script Not in qb-inv
Expected behavior
There will be more customization and the code will not be so large as to be distracting
Actual behavior
More independence
Additional context
No response
Last Updated
today
Custom Resources
qb-target
Resource Rename
no