diff --git a/bridge/qb/server.lua b/bridge/qb/server.lua index 9a5f80d..71039de 100644 --- a/bridge/qb/server.lua +++ b/bridge/qb/server.lua @@ -2,9 +2,11 @@ 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], true) + if GiveKeys(source, vehicles[i], true) then + success = true + end end if success then exports.qbx_core:Notify(source, locale('notify.keys_taken')) @@ -16,10 +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], true) + if RemoveKeys(source, vehicles[i], true) then + success = true + end end - exports.qbx_core:Notify(source, locale('notify.keys_removed')) + if success then + exports.qbx_core:Notify(source, locale('notify.keys_removed')) + end + return success end CreateQbExport('RemoveKeys', removeKeys)