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

View File

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