From 7a28f22f9931609a6b8166f39fba04e76eab3a59 Mon Sep 17 00:00:00 2001 From: Manason Date: Tue, 31 Oct 2023 21:57:10 -0700 Subject: [PATCH] feat(bridge/qb): add vehicle events --- bridge/qb/client/events.lua | 21 ++++++++++++++++++++ bridge/qb/server/events.lua | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 bridge/qb/server/events.lua diff --git a/bridge/qb/client/events.lua b/bridge/qb/client/events.lua index 97751fc60..0e2b9dc71 100644 --- a/bridge/qb/client/events.lua +++ b/bridge/qb/client/events.lua @@ -2,4 +2,25 @@ --- @deprecated RegisterNetEvent('QBCore:Command:CallCommand', function(command) ExecuteCommand(command) +end) + +RegisterNetEvent('QBCore:Client:VehicleInfo', function(info) + local plate = GetPlate(info.vehicle) + local hasKeys = true + + if GetResourceState('qb-vehiclekeys') == 'started' then + hasKeys = exports['qb-vehiclekeys']:HasKeys() + end + + local data = { + vehicle = info.vehicle, + seat = info.seat, + name = info.modelName, + plate = plate, + driver = GetPedInVehicleSeat(info.vehicle, -1), + inseat = GetPedInVehicleSeat(info.vehicle, info.seat), + haskeys = hasKeys + } + + TriggerEvent('QBCore:Client:'..info.event..'Vehicle', data) end) \ No newline at end of file diff --git a/bridge/qb/server/events.lua b/bridge/qb/server/events.lua new file mode 100644 index 000000000..22d416ef8 --- /dev/null +++ b/bridge/qb/server/events.lua @@ -0,0 +1,38 @@ +-- Vehicles +RegisterServerEvent('baseevents:enteringVehicle', function(veh,seat,modelName) + local src = source + local data = { + vehicle = veh, + seat = seat, + name = modelName, + event = 'Entering' + } + TriggerClientEvent('QBCore:Client:VehicleInfo', src, data) +end) + +RegisterServerEvent('baseevents:enteredVehicle', function(veh,seat,modelName) + local src = source + local data = { + vehicle = veh, + seat = seat, + name = modelName, + event = 'Entered' + } + TriggerClientEvent('QBCore:Client:VehicleInfo', src, data) +end) + +RegisterServerEvent('baseevents:enteringAborted', function() + local src = source + TriggerClientEvent('QBCore:Client:AbortVehicleEntering', src) +end) + +RegisterServerEvent('baseevents:leftVehicle', function(veh,seat,modelName) + local src = source + local data = { + vehicle = veh, + seat = seat, + name = modelName, + event = 'Left' + } + TriggerClientEvent('QBCore:Client:VehicleInfo', src, data) +end) \ No newline at end of file