Skip to content

Commit

Permalink
fix: getLastCall returning call even if it's old
Browse files Browse the repository at this point in the history
  • Loading branch information
TonybynMp4 committed May 2, 2024
1 parent 9a7c23f commit a7de21a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions html/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function RemoveCall() {
calls[0].classList.add("removing");

setTimeout(() => {
if (calls.length == 0) return;
calls[0].remove();
UpdateCalls();
fetch(`https://${GetParentResourceName()}/RemoveCall`, {
Expand Down
8 changes: 7 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ end
RegisterNetEvent('qbx_dispatch:server:RemoveCall', function()
if not calls then return end
for i = #calls, 1, -1 do
if calls[i].UnitsNotResponding[source] ~= true then
if not calls[i].UnitsNotResponding[source] then
calls[i].UnitsNotResponding[source] = true
break
end
Expand All @@ -79,8 +79,14 @@ end)

lib.callback.register('qbx_dispatch:server:GetLastCall', function(source)
for i = #calls, 1, -1 do
-- Stop at the first call older than 30 seconds
if os.time() - calls[i].time/1000 < 30000 then
return false
end
-- Only return the call if you didn't ignore it
if not calls[i].UnitsNotResponding[source] then
return {blipid = calls[i].id}
end
end
return false
end)

0 comments on commit a7de21a

Please sign in to comment.