refactor(resource/vehicleProperties): type fixes

This commit is contained in:
Linden
2022-09-18 11:33:17 +10:00
parent d08101c545
commit 0e1dfc78ba
2 changed files with 16 additions and 14 deletions

View File

@@ -6,9 +6,10 @@ interface VehicleProperties {
engineHealth: number;
tankHealth: number;
fuelLevel: number;
oilLevel: number;
dirtLevel: number;
color1: number;
color2: number;
color1: number | [number, number, number];
color2: number | [number, number, number];
pearlescentColor: number;
interiorColor: number;
dashboardColor: number;
@@ -40,15 +41,15 @@ interface VehicleProperties {
modSuspension: number;
modArmor: number;
modNitrous: number;
modTurbo: number;
modSubwoofer: number;
modSmokeEnabled: number;
modHydraulics: number;
modXenon: number;
modTurbo: boolean;
modSubwoofer: boolean;
modSmokeEnabled: boolean;
modHydraulics: boolean;
modXenon: boolean;
modFrontWheels: number;
modBackWheels: number;
modCustomTiresF: number;
modCustomTiresR: number;
modCustomTiresF: boolean;
modCustomTiresR: boolean;
modPlateHolder: number;
modVanityPlate: number;
modTrimA: number;
@@ -84,7 +85,8 @@ interface VehicleProperties {
rearBumper: boolean;
}
export const getVehicleProperties = (vehicle: number): VehicleProperties => exports.ox_lib.getVehicleProperties(vehicle);
export const getVehicleProperties = (vehicle: number): VehicleProperties =>
exports.ox_lib.getVehicleProperties(vehicle);
export const setVehicleProperties = (vehicle: number, props: Partial<VehicleProperties>): boolean =>
exports.ox_lib.setVehicleProperties(vehicle, props);

View File

@@ -8,8 +8,8 @@
---@field fuelLevel? number
---@field oilLevel? number
---@field dirtLevel? number
---@field color1? number
---@field color2? number
---@field color1? number | number[]
---@field color2? number | number[]
---@field pearlescentColor? number
---@field interiorColor? number
---@field dashboardColor? number
@@ -302,7 +302,7 @@ function lib.setVehicleProperties(vehicle, props)
if props.color1 then
if type(props.color1) == 'number' then
SetVehicleColours(vehicle, props.color1, colorSecondary)
SetVehicleColours(vehicle, props.color1 --[[@as number]], colorSecondary --[[@as number]])
else
SetVehicleCustomPrimaryColour(vehicle, props.color1[1], props.color1[2], props.color1[3])
end
@@ -310,7 +310,7 @@ function lib.setVehicleProperties(vehicle, props)
if props.color2 then
if type(props.color2) == 'number' then
SetVehicleColours(vehicle, props.color1 or colorPrimary, props.color2)
SetVehicleColours(vehicle, props.color1 or colorPrimary --[[@as number]], props.color2 --[[@as number]])
else
SetVehicleCustomSecondaryColour(vehicle, props.color2[1], props.color2[2], props.color2[3])
end