I wan't every car to be clean when spawning

So i know that there is the native "void SET_VEHICLE_DIRT_LEVEL(Vehicle vehicle, float dirtLevel); " but honestly i didnt understand yet how to make a script out of a native. I think its pretty easy to do but i just suck so hopefully someone can help me. :slight_smile:

Hello @manu102.

What type of system do you use to spawn the cars?

You need to use the natives:

local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
SetVehicleDirtLevel(vehicle, 0.0)

That code should fix you’r problem. :slight_smile:

I mainly want the cars to be clean when they appear in esx_vehicleshop and after spawning from esx_advancedgarage. I just don’t know if I have to add this code inside those scripts or in a seperate script.

You have to add them inside the scripts and inside the events that trigger the car to be spawned. The vehicle in SetVehicleDirtLevel has to be defined already. In your example for the vehicle shop add it below line 249 https://github.com/ESX-Org/esx_vehicleshop/blob/master/client/main.lua#L249

And since they used vehicle as the name already then SetVehicleDirtLevel(vehicle, 0.0) is all you are going to need.

Thanks thats a good first step and works fine. The cars are clear when purchased but i want them to be clean in the preview aswell. Can you give me the right line for this aswell I can’t find where to put the code there.

Should be able to add the same code above after line 289.

1 Like

Big thanks it works fine!