forked from Simnation/Main
ed
This commit is contained in:
parent
1301dfa7ad
commit
64fecd2fa0
2 changed files with 267 additions and 240 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue