[Release] Car damage system

Creates a health function for the vehicle, giving you a control to when it can break because damage.

Download

13 Likes

Thank you sir! I was having one heck of a time trying to fix car crash. And this is Lua so easily changeable, unlike .DLLs that require visuals.

1 Like

I’ll test that for sure :slight_smile:
Any idea on how a player can repair the vehicle ? :slight_smile:

Thanks for the release :slight_smile:

it doesn’t have a repair feature, use it with the towtruck for the moment and i will add a repair option for triple A or something similar maybe to a job. the script is set for the engine to break at 85% and i sugest to not change that ( trust me , it;s a lot anyway ) because GTA logic on crash is not that good, you can crash a few times for 85% .

2 Likes

Thank you again HBK, for your answer and your release. Works perfectly :slight_smile:

hello i found bug with getEntityHealt (getEntityHealt use GetVehicleBodyHealth(playerCar))
if you shoot in windows this vehicle take damage (if shoot with assaut rifle vehicle is healt = 0 just with window)

my advice use GetVehicleEngineHealth(playerCar) for result in damage engine degat taken just with engine (dont work in crash with rear engine)

Citizen.CreateThread(function()

	while true do

		
		Citizen.Wait(0)

		playerPed = GetPlayerPed(-1)
		if playerPed then
			playerCar = GetVehiclePedIsIn(playerPed, false)
			if playerCar and GetPedInVehicleSeat(playerCar, -1) == playerPed then
				Citizen.Wait(200)
		
				if GetVehicleEngineHealth(playerCar) < 960 then --max 1000 min 0
				   SetVehicleUndriveable(playerCar, 1)
				   -- tester si je tire dessus voir le resultat
				end
			end
		end

	end
end)

Thanks a lot! This is exactly what we need for the mechanic job

For information there is a function/resource for a another heal information.
GetVehicleBodyHealth OR GetVehicleBodyHealth_2 (same information, not the same value type) (one 0 to 1000 and other 0.0 to 100.0)
GetVehicleEngineHealth (0 to 1000, if < 0 the motor start to burn and at a moment the car explod) (there have two smokes white if value < 200, black if value < 100 or 20, need to confirm values)
(is maybe a good idee to setdamage to 10 when you make the car undrivable to see the motor smoke)

There GetVehiclePetrolTankHealth but i’m not sure if is only for the tow/trailer

For flight veh (not tested at the moment) :
GetHeliTailRotorHealth
GetHeliMainRotorHealth
GetHeliEngineHealth

sorry for my bad english

1 Like

Thank you! We needed this

this was just the beginning, script will be related to car engine so that a mechanic can be able to fix it, i was just getting bored of that dll that was not working at all.

1 Like

and whats the function for setting the vehicle damage?

1 Like

there is not, the function to create a return in % was made by me, i would need to create that for engine

try SetVehicleBodyHealth

void Native.SetVehicleBodyHealth(int vehicle, float value)
Native N° : B77D05AC8C78AADB

CF: https://wiki.fivem.net/w/index.php?title=List_of_native_functions&mobileaction=toggle_view_mobile

thanks for this release !

1 Like

Nice release dude !!

Hi I have installed the script its works great parked shows ya a worry if I kick in the car it breaks down and it can modify its

Can someone show this script with the engine smoke option?

Ive got something going on that works, but youll have to wait till Iet home in a few hours :stuck_out_tongue:

1 Like

Thank you very much…

Also anyone know why personal vehicles do not take any damage with this script??

Just a question, actually there is no script to repair vehicule, right ?