[ESX] How to save vehicle damage

Hello there,

I’ll show you how you can save the vehicle damage when you store your car at any garage script. It also keeps it saved if you restart the server.

At \es_extended\client\functions.lua

Add this like so:

health = GetVehicleEngineHealth(vehicle)

And add this like so:

if props.health ~= nil then
SetVehicleEngineHealth(vehicle, props.health+0.00)
end

Further help comment down below and I’ll try to help you out.

10 Likes

Can confirm this works.

If you’re using esx_advancedgarage, then you will have to go into the client side and edit the code that repairs your vehicle upon storing it.

1 Like

how bout eden garage is that work or nah ?

Yes, I personally use eden garage v2 and works flawlessly. As far as I know and tested it also works with Kuana garage

2 Likes

Have you figured out how to store appearance damages?

2 Likes

what do i need to change in esx_advancedgarage ? :slight_smile:

It’s not working for me, i have edited es_extended, i have no idea what i have to edit in esx_advancedgarage? it seems like something wrong.

	if props.modLivery ~= nil then
		SetVehicleMod(vehicle, 48, props.modLivery, false)
		SetVehicleLivery(vehicle, props.modLivery)
	end

    if props.health ~= nil then
	SetVehicleEngineHealth(vehicle, props.health+0.00)
end

		modWindows        = GetVehicleMod(vehicle, 46),
		modLivery         = GetVehicleLivery(vehicle),
		health            = GetVehicleEngineHealth(vehicle)
	}
end

This is how mine does looks like, at the end of each one i changed, anything else i have to change?

You have everything correctly, I’ve never used esx_advancedgarage so can’t help you in what you have to edit further, considerer asking this guy Michael8t6 since he uses esx_advancegarage, I can only help you in kuana garage or eden garage v2

I hade this wrong, this is why it was not working lol
What i had:

    if props.health ~= nil then
	SetVehicleEngineHealth(vehicle, props.health+0.00)
end

What i should have:

    if props.health ~= nil then
	SetVehicleEngineHealth(vehicle, props.health+0.00)
    end
end
1 Like

After following the steps, with esx_advancedgarage, I can store the car if its 100% but if it has any damage on it, nothing happens, it doesn’t put the car away. Any idea why?

Do we know the general bias of how to do this for esx_advanced garage?

Looking at Advanced Garage in theory it should be replacing this in client\main.lua

if valid then
				if engineHealth < 990 then
					if Config.UseDamageMult then
						local apprasial = math.floor((1000 - engineHealth)/1000*Config.CarPoundPrice*Config.DamageMult)
						reparation(apprasial, vehicle, vehicleProps)
					else
						local apprasial = math.floor((1000 - engineHealth)/1000*Config.CarPoundPrice)
						reparation(apprasial, vehicle, vehicleProps)
					end
				else
					putaway(vehicle, vehicleProps)
				end	
			else

With this

if valid then	
		putaway(vehicle, vehicleProps)
	else

Sorry I’m at work so can’t test 100% but that’s what I see with a quick glance

Edit: Can confirm as working and also added in the following to make damage available to view in the garage:

change this part of the client\main.lua

local hashVehicule = v.vehicle.model
local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
local plate        = v.plate
local labelvehicle
					
if Config.ShowVehicleLocation then
	if v.stored then
		labelvehicle = '| '..plate..' | '..vehicleName..' | '.._U('loc_garage')..' |'
	else
		labelvehicle = '| '..plate..' | '..vehicleName..' | '.._U('loc_pound')..' |'
	end
else
	if v.stored then
		labelvehicle = '| '..plate..' | '..vehicleName..' |'
	else
		labelvehicle = '| '..plate..' | '..vehicleName..' |'
	end
end

to

local hashVehicule = v.vehicle.model
local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
local plate        = v.plate
local vehDamage	   = math.floor(v.vehicle.health/10)
local labelvehicle
					
if Config.ShowVehicleLocation then
	if v.stored then
		labelvehicle = '| '..plate..' | '..vehicleName..' | '.._U('loc_garage')..' | '..vehDamage..'% '
	else
		labelvehicle = '| '..plate..' | '..vehicleName..' | '.._U('loc_pound')..' | '..vehDamage..'% '
	end
else
	if v.stored then
		labelvehicle = '| '..plate..' | '..vehicleName..' | '..vehDamage..'% '
	else
		labelvehicle = '| '..plate..' | '..vehicleName..' | '..vehDamage..'% '
	end
end
1 Like

It’s not wroking for me, the only thing that is working is the engine, but when the car parts are broken/damaged it wont save them when i take it out again from the garage, i’m using esx_advancedgarage

It’s working, it just doesn’t save vehcile apparence damage

Maybe you could try to detect if a player take out his car and for exemple his engine life is below 300 ( I don’t remember how many health an engine have) it remove for exemple some random doors and destroy the glasses to make it look broken?

So, to be clear to everyone this only saves vehicle damage, not vehicle appearance, for that you need to add a couple more lines. With that said this guy may be able to help you out guys, hit em up and ask him politily Jager_Bom

i’m using eden garage and was wondering if I could show the state of the car in the menu to get a vehicle. also was wondering how to save the appearance if anyone could help

Hi, can you help me with eden garage? i made all the steps but it tell me to pay to store the car, and don`t know how to take it oute

Hello there! When I follow the steps you said, I can’t open the menu and I get the following error.
Can you help me!!? please
I am using:esx_advancedgarage

tried those codes but its not working. Cars are coming out with full health