diff --git a/bridge/qb/server.lua b/bridge/qb/server.lua index b7c6b1d..71039de 100644 --- a/bridge/qb/server.lua +++ b/bridge/qb/server.lua @@ -2,9 +2,14 @@ if GetConvar('qbx_vehiclekeys:enableBridge', 'true') ~= 'true' then return end local function giveKeys(source, plate) local vehicles = plate and GetVehiclesFromPlate(plate) or {GetVehiclePedIsIn(GetPlayerPed(source), false)} - local success = nil + local success = false for i = 1, #vehicles do - success = success or GiveKeys(source, vehicles[i]) + if GiveKeys(source, vehicles[i], true) then + success = true + end + end + if success then + exports.qbx_core:Notify(source, locale('notify.keys_taken')) end return success end @@ -13,9 +18,16 @@ CreateQbExport('GiveKeys', giveKeys) local function removeKeys(source, plate) local vehicles = GetVehiclesFromPlate(plate) + local success = false for i = 1, #vehicles do - RemoveKeys(source, vehicles[i]) + if RemoveKeys(source, vehicles[i], true) then + success = true + end end + if success then + exports.qbx_core:Notify(source, locale('notify.keys_removed')) + end + return success end CreateQbExport('RemoveKeys', removeKeys) diff --git a/server/keys.lua b/server/keys.lua index 30665c9..0d91db4 100644 --- a/server/keys.lua +++ b/server/keys.lua @@ -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 @@ -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 @@ -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 @@ -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