1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-29 23:24:42 +02:00
parent 1301dfa7ad
commit 64fecd2fa0
2 changed files with 267 additions and 240 deletions

View file

@ -712,4 +712,39 @@ QBCore.Commands.Add('vendingdebug', 'Debug vending machines (Admin Only)', {}, f
end
end, 'admin')
-- Combined callback for faster machine status checks
QBCore.Functions.CreateCallback('vending:server:getMachineStatus', function(source, cb, coords)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then
cb(nil)
return
end
local machineId = getMachineIdByCoords(coords)
if not machineId then
cb({exists = false, canManage = false})
return
end
local machine = vendingMachines[machineId]
local canManage = false
-- Check if player is owner
if machine.owner == Player.PlayerData.citizenid then
canManage = true
else
-- Check if player is manager
if machine.managers then
for _, manager in pairs(machine.managers) do
if manager == Player.PlayerData.citizenid then
canManage = true
break
end
end
end
end
cb({exists = true, canManage = canManage})
end)