Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Moozdzn committed Jun 20, 2023
2 parents 4a955d8 + 7816ce7 commit 3a947f2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
56 changes: 32 additions & 24 deletions resource/vehicleProperties/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if cache.game == 'redm' then return end
---@field xenonColor? number
---@field neonEnabled? boolean[]
---@field neonColor? number | number[]
---@field extras? boolean[]
---@field extras? table<number | string, 0 | 1>
---@field tyreSmokeColor? number | number[]
---@field modSpoilers? number
---@field modFrontBumper? number
Expand Down Expand Up @@ -83,7 +83,8 @@ if cache.game == 'redm' then return end
---@field modLightbar? number
---@field windows? number[]
---@field doors? number[]
---@field tyres? number[]
---@field tyres? table<number | string, 1 | 2>
---@field bulletProofTyres? boolean

RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
local timeout = 100
Expand Down Expand Up @@ -146,7 +147,7 @@ function lib.getVehicleProperties(vehicle)
end
end

for i = 0, 5 do
for i = 0, 7 do
if IsVehicleTyreBurst(vehicle, i, false) then
damage.tyres[i] = IsVehicleTyreBurst(vehicle, i, true) and 2 or 1
end
Expand Down Expand Up @@ -242,6 +243,7 @@ function lib.getVehicleProperties(vehicle)
windows = damage.windows,
doors = damage.doors,
tyres = damage.tyres,
bulletProofTyres = GetVehicleTyresCanBurst(vehicle),
-- no setters?
-- leftHeadlight = GetIsLeftVehicleHeadlightDamaged(vehicle),
-- rightHeadlight = GetIsRightVehicleHeadlightDamaged(vehicle),
Expand All @@ -258,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)"):
format(vehicle))
end

if NetworkGetEntityIsNetworked(vehicle) and NetworkGetEntityOwner(vehicle) ~= cache.playerId then error((
"Unable to set vehicle properties for '%s' (client is not entity owner)"):format(vehicle))
end
Expand Down Expand Up @@ -366,6 +369,30 @@ function lib.setVehicleProperties(vehicle, props)
end
end

if props.extras then
for id, disable in pairs(props.extras) do
SetVehicleExtra(vehicle, tonumber(id) --[[@as number]], disable == 1)
end
end

if props.windows then
for i = 1, #props.windows do
SmashVehicleWindow(vehicle, props.windows[i])
end
end

if props.doors then
for i = 1, #props.doors do
SetVehicleDoorBroken(vehicle, props.doors[i], true)
end
end

if props.tyres then
for tyre, state in pairs(props.tyres) do
SetVehicleTyreBurst(vehicle, tonumber(tyre) --[[@as number]], state == 2, 1000.0)
end
end

if props.neonColor then
SetVehicleNeonLightsColour(vehicle, props.neonColor[1], props.neonColor[2], props.neonColor[3])
end
Expand Down Expand Up @@ -588,27 +615,8 @@ function lib.setVehicleProperties(vehicle, props)
SetVehicleMod(vehicle, 49, props.modLightbar, false)
end

if props.windows then
for i = 1, #props.windows do
SmashVehicleWindow(vehicle, props.windows[i])
end
end

if props.doors then
for i = 1, #props.doors do
SetVehicleDoorBroken(vehicle, props.doors[i], true)
end
end

if props.tyres then
for tyre, state in pairs(props.tyres) do
tyre = tonumber(tyre) --[[ @as number ]]
if state == 1 then
SetVehicleTyreBurst(vehicle, tyre, false, 1000.0)
else
SetVehicleTyreBurst(vehicle, tyre, true, 1000.0)
end
end
if props.bulletProofTyres ~= nil then
SetVehicleTyresCanBurst(vehicle, props.bulletProofTyres)
end

return true
Expand Down
6 changes: 5 additions & 1 deletion web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a947f2

Please sign in to comment.