Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only giving keys to one vehicle
Browse files Browse the repository at this point in the history
Manason committed Oct 3, 2024
1 parent b0c33ea commit 1ee84da
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bridge/qb/server.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1ee84da

Please sign in to comment.