#[Tablet] - dispatch circles won't get removed
6 messages · Page 1 of 1 (latest)
Please follow #1035615248327131146
Product: Tablet
Issue: Cant remove the dispatch circle using RemoveDispatch(dispatchId)
When: When trying to remove the dispatch we get a return that the dispatchId's are removed, but are not removed.
How to recreate: Try to use exports["lb-tablet"]:RemoveDispatch(dispatchId)
Does this happen for everyone: Yes.
Attachment: Added example
Version: 1.1.4
Framework: Qbox
Has this bug appeared more than once? If so, how often?: Everytime we try to remove dispatch circles.
Example:
local dispatchIDS = {}
local currentMeldingID = 0
lib.cron.new("* * * * *", function(task, date)
local currentTime = os.time()
for i = #dispatchIDS, 1, -1 do -- Itereer achteruit om veilig items te verwijderen
local dispatchEntry = dispatchIDS[i]
if dispatchEntry and dispatchEntry.createdAt then
if (currentTime - dispatchEntry.createdAt) >= 60 then -- 1800 seconden = 30 minuten
local success = exports["lb-tablet"]:RemoveDispatch(dispatchEntry.dispatchId)
if success then
print("Dispatch ID " .. dispatchEntry.dispatchId .. " is na 60 seconden verwijderd.")
else
print("Failed to remove Dispatch ID " .. dispatchEntry.dispatchId)
end
table.remove(dispatchIDS, i)
end
end
end
end, { debug = false })
lib.addCommand('112', {
help = 'Melding maken bij de ambulance',
params = {},
restricted = false
}, function(source, args)
local src = source
local Player = exports.qbx_core:GetPlayer(source)
if not Player then return end
local phone = Player.Functions.GetItemByName('phone')
if not phone then
lib.notify(src, {
description = 'Je hebt geen telefoon op zak?',
type = 'warning',
iconAnimation = 'beatFade'
})
return
end
local coords = GetEntityCoords(GetPlayerPed(src))
local phoneNumber = exports["lb-phone"]:GetEquippedPhoneNumber(Player.PlayerData.source) or 'Onbekend'
-- Verhoog de currentMeldingID voor de nieuwe melding
currentMeldingID = currentMeldingID + 1
local dispatch = {
priority = 'high',
code = '112',
title = 'Medische assistentie gevraagd',
description = 'ID: ' .. currentMeldingID .. ' | Tijd: ' .. os.date("%H:%M:%S") .. ' | Burger: ' .. Player.PlayerData.charinfo.firstname,
location = {
label = "Melder locatie",
coords = vector2(coords.x, coords.y)
},
time = 90,
job = 'ambulance',
fields = {
{ icon = "fa-solid fa-user", label = "Melder", value = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname },
{ icon = "fa-solid fa-phone", label = "Telefoonnummer", value = phoneNumber },
{ icon = "fa-solid fa-clock", label = "Tijdstip melding", value = os.date("%H:%M:%S") },
{ icon = "fa-solid fa-comment", label = "Melding ID", value = tostring(currentMeldingID) }
}
}
local dispatchId = exports["lb-tablet"]:AddDispatch(dispatch)
if dispatchId then
print("Dispatch ID " .. dispatchId .. " is aangemaakt.")
print("Melding ID: " .. currentMeldingID)
print("createdAt: " .. os.time())
table.insert(dispatchIDS, { dispatchId = dispatchId, createdAt = os.time() })
lib.notify(src, {
description = 'Je hebt een melding gemaakt naar de ambulance!',
type = 'success',
iconAnimation = 'beatFade'
})
else
lib.notify(src, {
description = 'Melding mislukt!',
type = 'error',
iconAnimation = 'beatFade'
})
end
end)
There you go