feat(client/vehicleProperties): support extra props

Add modKit and bulletProofTyres.
This commit is contained in:
Linden
2023-05-22 03:38:36 +10:00
parent 3bc9c3206d
commit b4edc5bac6
2 changed files with 13 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ interface VehicleProperties {
neonColor: [number, number, number]; neonColor: [number, number, number];
extras: boolean[]; extras: boolean[];
tyreSmokeColor: [number, number, number]; tyreSmokeColor: [number, number, number];
modKit: number;
modSpoilers: number; modSpoilers: number;
modFrontBumper: number; modFrontBumper: number;
modRearBumper: number; modRearBumper: number;
@@ -83,6 +84,7 @@ interface VehicleProperties {
rightHeadlight: boolean; rightHeadlight: boolean;
frontBumper: boolean; frontBumper: boolean;
rearBumper: boolean; rearBumper: boolean;
bulletProofTyres: boolean;
} }
export const getVehicleProperties = (vehicle: number): VehicleProperties => export const getVehicleProperties = (vehicle: number): VehicleProperties =>

View File

@@ -25,6 +25,7 @@ if cache.game == 'redm' then return end
---@field neonColor? number | number[] ---@field neonColor? number | number[]
---@field extras? boolean[] ---@field extras? boolean[]
---@field tyreSmokeColor? number | number[] ---@field tyreSmokeColor? number | number[]
---@field modKit number
---@field modSpoilers? number ---@field modSpoilers? number
---@field modFrontBumper? number ---@field modFrontBumper? number
---@field modRearBumper? number ---@field modRearBumper? number
@@ -81,6 +82,7 @@ if cache.game == 'redm' then return end
---@field windows? number[] ---@field windows? number[]
---@field doors? number[] ---@field doors? number[]
---@field tyres? number[] ---@field tyres? number[]
---@field bulletProofTyres? boolean
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data) RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
local timeout = 100 local timeout = 100
@@ -160,6 +162,7 @@ function lib.getVehicleProperties(vehicle)
end end
return { return {
modKit = GetVehicleModKit(vehicle),
model = GetEntityModel(vehicle), model = GetEntityModel(vehicle),
plate = GetVehicleNumberPlateText(vehicle), plate = GetVehicleNumberPlateText(vehicle),
plateIndex = GetVehicleNumberPlateTextIndex(vehicle), plateIndex = GetVehicleNumberPlateTextIndex(vehicle),
@@ -240,6 +243,7 @@ function lib.getVehicleProperties(vehicle)
windows = damage.windows, windows = damage.windows,
doors = damage.doors, doors = damage.doors,
tyres = damage.tyres, tyres = damage.tyres,
bulletProofTyres = GetVehicleTyresCanBurst(vehicle),
-- no setters? -- no setters?
-- leftHeadlight = GetIsLeftVehicleHeadlightDamaged(vehicle), -- leftHeadlight = GetIsLeftVehicleHeadlightDamaged(vehicle),
-- rightHeadlight = GetIsRightVehicleHeadlightDamaged(vehicle), -- rightHeadlight = GetIsRightVehicleHeadlightDamaged(vehicle),
@@ -256,6 +260,7 @@ function lib.setVehicleProperties(vehicle, props)
if not DoesEntityExist(vehicle) then error(("Unable to set vehicle properties for '%s' (entity does not exist)"): if not DoesEntityExist(vehicle) then error(("Unable to set vehicle properties for '%s' (entity does not exist)"):
format(vehicle)) format(vehicle))
end end
if NetworkGetEntityIsNetworked(vehicle) and NetworkGetEntityOwner(vehicle) ~= cache.playerId then error(( if NetworkGetEntityIsNetworked(vehicle) and NetworkGetEntityOwner(vehicle) ~= cache.playerId then error((
"Unable to set vehicle properties for '%s' (client is not entity owner)"):format(vehicle)) "Unable to set vehicle properties for '%s' (client is not entity owner)"):format(vehicle))
end end
@@ -263,7 +268,7 @@ function lib.setVehicleProperties(vehicle, props)
local colorPrimary, colorSecondary = GetVehicleColours(vehicle) local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle) local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
SetVehicleModKit(vehicle, 0) SetVehicleModKit(vehicle, props.modKit or 0)
SetVehicleAutoRepairDisabled(vehicle, true) SetVehicleAutoRepairDisabled(vehicle, true)
if props.plate then if props.plate then
@@ -368,11 +373,7 @@ function lib.setVehicleProperties(vehicle, props)
if props.tyres then if props.tyres then
for tyre, state in pairs(props.tyres) do for tyre, state in pairs(props.tyres) do
if state == 1 then SetVehicleTyreBurst(vehicle, tyre, state == 2, 1000.0)
SetVehicleTyreBurst(vehicle, tyre, false, 1000.0)
else
SetVehicleTyreBurst(vehicle, tyre, true, 1000.0)
end
end end
end end
@@ -593,5 +594,9 @@ function lib.setVehicleProperties(vehicle, props)
SetVehicleMod(vehicle, 49, props.modLightbar, false) SetVehicleMod(vehicle, 49, props.modLightbar, false)
end end
if props.bulletProofTyres ~= nil then
SetVehicleTyresCanBurst(vehicle, props.bulletProofTyres)
end
return true return true
end end