Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client/vehicleproperties): vehicle must be fixed for extras to apply visually #392

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions resource/vehicleProperties/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,16 @@ end

---@param vehicle number
---@param props VehicleProperties
---@param fixVehicle? boolean
---@return boolean?
function lib.setVehicleProperties(vehicle, props)
if not DoesEntityExist(vehicle) then error(("Unable to set vehicle properties for '%s' (entity does not exist)"):
format(vehicle))
function lib.setVehicleProperties(vehicle, props, fixVehicle)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires TS definition.

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((
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 All @@ -291,6 +294,12 @@ function lib.setVehicleProperties(vehicle, props)
SetVehicleModKit(vehicle, 0)
SetVehicleAutoRepairDisabled(vehicle, true)

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

Comment on lines +297 to +302
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this moved up?

if props.plate then
SetVehicleNumberPlateText(vehicle, props.plate)
end
Expand Down Expand Up @@ -375,12 +384,6 @@ 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
RemoveVehicleWindow(vehicle, props.windows[i])
Expand Down Expand Up @@ -624,5 +627,9 @@ function lib.setVehicleProperties(vehicle, props)
SetDriftTyresEnabled(vehicle, true)
end

if fixVehicle then
SetVehicleFixed(vehicle)
end

return true
end