mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(client/vehicleproperties): add fixVehicle parameter (#392)
This commit is contained in:
@@ -281,13 +281,16 @@ end
|
||||
|
||||
---@param vehicle number
|
||||
---@param props VehicleProperties
|
||||
---@param fixVehicle? boolean Fix the vehicle after props have been set. Usually required when adding extras.
|
||||
---@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)
|
||||
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
|
||||
|
||||
@@ -297,6 +300,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
|
||||
|
||||
if props.plate then
|
||||
SetVehicleNumberPlateText(vehicle, props.plate)
|
||||
end
|
||||
@@ -385,12 +394,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])
|
||||
@@ -634,5 +637,9 @@ function lib.setVehicleProperties(vehicle, props)
|
||||
SetDriftTyresEnabled(vehicle, true)
|
||||
end
|
||||
|
||||
if fixVehicle then
|
||||
SetVehicleFixed(vehicle)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user