Skip to content

Commit

Permalink
fix: notify spam
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Oct 3, 2024
1 parent 51f1a3a commit b0c33ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions bridge/qb/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ local function giveKeys(source, plate)
local vehicles = plate and GetVehiclesFromPlate(plate) or {GetVehiclePedIsIn(GetPlayerPed(source), false)}
local success = nil
for i = 1, #vehicles do
success = success or GiveKeys(source, vehicles[i])
success = success or GiveKeys(source, vehicles[i], true)
end
if success then
exports.qbx_core:Notify(source, locale('notify.keys_taken'))
end
return success
end
Expand All @@ -14,8 +17,9 @@ CreateQbExport('GiveKeys', giveKeys)
local function removeKeys(source, plate)
local vehicles = GetVehiclesFromPlate(plate)
for i = 1, #vehicles do
RemoveKeys(source, vehicles[i])
RemoveKeys(source, vehicles[i], true)
end
exports.qbx_core:Notify(source, locale('notify.keys_removed'))
end

CreateQbExport('RemoveKeys', removeKeys)
Expand Down
14 changes: 10 additions & 4 deletions server/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ end, {debug = debug})
--- Removing the vehicle keys from the user
---@param source number ID of the player
---@param vehicle number
function RemoveKeys(source, vehicle)
---@param skipNotification? boolean
function RemoveKeys(source, vehicle, skipNotification)
local citizenid = getCitizenId(source)
if not citizenid then return end

Expand All @@ -73,7 +74,9 @@ function RemoveKeys(source, vehicle)
Player(source).state:set('keysList', keys, true)

TriggerClientEvent('qbx_vehiclekeys:client:OnLostKeys', source)
exports.qbx_core:Notify(source, locale('notify.keys_removed'))
if not skipNotification then
exports.qbx_core:Notify(source, locale('notify.keys_removed'))
end

return true
end
Expand All @@ -82,7 +85,8 @@ exports('RemoveKeys', RemoveKeys)

---@param source number
---@param vehicle number
function GiveKeys(source, vehicle)
---@param skipNotification? boolean
function GiveKeys(source, vehicle, skipNotification)
local citizenid = getCitizenId(source)
if not citizenid then return end

Expand All @@ -93,7 +97,9 @@ function GiveKeys(source, vehicle)
keys[sessionId] = true

Player(source).state:set('keysList', keys, true)
exports.qbx_core:Notify(source, locale('notify.keys_taken'))
if not skipNotification then
exports.qbx_core:Notify(source, locale('notify.keys_taken'))
end
return true
end

Expand Down

0 comments on commit b0c33ea

Please sign in to comment.