-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
if GetConvar('qbx_vehiclekeys:enableBridge', 'true') ~= 'true' then return end | ||
|
||
RegisterNetEvent('qb-vehiclekeys:client:AddKeys', function(plate) | ||
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) | ||
end) | ||
|
||
RegisterNetEvent('qb-vehiclekeys:client:RemoveKeys', function(plate) | ||
TriggerServerEvent('qb-vehiclekeys:server:removeKeys', plate) | ||
end) | ||
|
||
RegisterNetEvent('vehiclekeys:client:SetOwner', function(plate) | ||
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 | ||
for i = 1, #vehicles do | ||
success = success or GiveKeys(source, vehicles[i]) | ||
end | ||
return success | ||
end | ||
|
||
CreateQbExport('GiveKeys', giveKeys) | ||
|
||
local function removeKeys(source, plate) | ||
local vehicles = GetVehiclesFromPlate(plate) | ||
for i = 1, #vehicles do | ||
RemoveKeys(source, vehicles[i]) | ||
end | ||
end | ||
|
||
CreateQbExport('RemoveKeys', removeKeys) | ||
|
||
RegisterNetEvent('qb-vehiclekeys:server:AcquireVehicleKeys', function(plate) | ||
giveKeys(source, plate) | ||
end) | ||
|
||
RegisterNetEvent('qb-vehiclekeys:server:removeKeys', function(plate) | ||
removeKeys(source, plate) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
if GetConvar('qbx_vehiclekeys:enableBridge', 'true') ~= 'true' then return end | ||
|
||
function CreateQbExport(name, cb) | ||
AddEventHandler(('__cfx_export_qb-vehiclekeys_%s'):format(name), function(setCB) | ||
setCB(cb) | ||
end) | ||
end | ||
|
||
function GetVehiclesFromPlate(plate) | ||
local vehicles = GetAllVehicles() | ||
local vehEntityFromPlate = {} | ||
|
||
for i = 1, #vehicles do | ||
local vehicle = vehicles[i] | ||
local vehPlate = qbx.getVehiclePlate(vehicle) | ||
if plate == vehPlate then | ||
vehEntityFromPlate[#vehEntityFromPlate + 1] = vehicle | ||
end | ||
end | ||
|
||
return vehEntityFromPlate | ||
end | ||
|
||
CreateQbExport('HasKeys', function(source, plate) | ||
local vehicles = GetVehiclesFromPlate(plate) | ||
local success = nil | ||
for i = 1, #vehicles do | ||
success = success or HasKeys(source, vehicles[i]) | ||
end | ||
return success | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters