See description for changes

Fixed the "health" problems on vehicles. It seems like you shouldn't use the `GetEntityHealth()` on vehicles at all since it is linked to the `GetVehicleBodyHealth()` native.
But if you use the `SetEntityHealth()` native on an vehicle it breaks the link. Instead there's both body health and engine health that ESX has missed out on.
Since the new used `GetVehicle***` natives return decimal values we round them to 1 decmial.
Also dirt levels are now rounded to one decimal since they make 0 visable difference.
This commit is contained in:
ElPumpo
2019-07-30 20:40:39 +02:00
parent 63bdd6daef
commit e850da085e
+9 -5
View File
@@ -638,15 +638,15 @@ ESX.Game.GetVehicleProperties = function(vehicle)
end
return {
model = GetEntityModel(vehicle),
plate = ESX.Math.Trim(GetVehicleNumberPlateText(vehicle)),
plateIndex = GetVehicleNumberPlateTextIndex(vehicle),
health = GetEntityHealth(vehicle),
dirtLevel = GetVehicleDirtLevel(vehicle),
bodyHealth = ESX.Math.Round(GetVehicleBodyHealth(vehicle), 1),
engineHealth = ESX.Math.Round(GetVehicleEngineHealth(vehicle), 1),
dirtLevel = ESX.Math.Round(GetVehicleDirtLevel(vehicle), 1),
color1 = color1,
color2 = color2,
@@ -731,8 +731,12 @@ ESX.Game.SetVehicleProperties = function(vehicle, props)
SetVehicleNumberPlateTextIndex(vehicle, props.plateIndex)
end
if props.health ~= nil then
SetEntityHealth(vehicle, props.health)
if props.bodyHealth ~= nil then
SetVehicleBodyHealth(vehicle, props.bodyHealth)
end
if props.engineHealth ~= nil then
SetVehicleEngineHealth(vehicle, props.engineHealth)
end
if props.dirtLevel ~= nil then