Skip to content

Commit

Permalink
feat(bridge/qb): add vehicle events
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Nov 1, 2023
1 parent 8c8d4f0 commit 7a28f22
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bridge/qb/client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
38 changes: 38 additions & 0 deletions bridge/qb/server/events.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7a28f22

Please sign in to comment.