Clean Car on spawn or disable car dirt?



Is it possible to clean the cars that the PED spans in on vRP.

I have the following code in the basic_garage.lua but it doesn’t work:


If not can you disable the dirt on cars both client or server sided?


just use this resource to wash cars


That’s where i got the code from. Doesn’t seem to work:

    -- spawn car
    if HasModelLoaded(mhash) then
      local x,y,z = tvRP.getPosition()
      if pos then
        x,y,z = table.unpack(pos)

      local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
      local vehicleClass = GetVehicleClass(vehicle)
      local nveh = CreateVehicle(mhash, x,y,z+0.5, 0.0, true, false)
      SetPedIntoVehicle(GetPlayerPed(-1),nveh,-1) -- put player inside
      GetVehicleDirtLevel(GetVehiclePedIsIn(GetPlayerPed(-1),false)) -- Clean Car On Spawn
      SetVehicleNumberPlateText(nveh, "P "..tvRP.getRegistrationNumber())
      Citizen.InvokeNative(0xAD738C3085FE7E11, nveh, true, true) -- set as mission entity

      if not cfg.vehicle_migration then
        local nid = NetworkGetNetworkIdFromEntity(nveh)

      vehicles[vtype] = {vtype,name,nveh} -- set current vehicule


    tvRP.notify("You can only have one "..vtype.." vehicle out.")


Could this be the better working version do you think?

WashDecalsFromVehicle(GetVehiclePedIsUsing(GetPlayerPed(-1)), 1.0)



Replace “GetVehiclePedIsIn(GetPlayerPed(-1), false)” with the variable “nveh”

And in the code snipet you posted you’re getting the dirt level, not setting it



Is that it then?



no, just like this: “SetVehicleDirtLevel(nveh)”


Why would you set it to some weird variable?
To clean a car use this, it will remove all dirt, dust and blood like decal effects:

local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
WashDecalsFromVehicle(vehicle, 1.0)

If you want to be super clean you can also add this below the example above:

This will remove all dirt and dust off your vehicle, it will NOT remove any blood or similar effects.

SetVehicleDirtLevel(vehicle, 0.0)

For some reason that seems to also make your car stay clean slightly longer. However it’s probably random and doesn’t actually improve it. Just seems like it does.


@Vespura sure it is clearly a wierd variable, did you read his code snippet ?

local nveh = CreateVehicle(mhash, x,y,z+0.5, 0.0, true, false)


I thought that snippet was some other script, and that the OP was only interested in finding a way to clean the player’s current vehicle, but in that case it makes sense :wink:

Still, SetVehicleDirtLevel(nveh) is not the way you should do it, it might work. But you should still use SetVehicleDirtLevel(nveh, 0.0) or WashDecalsFromVehicle(vehicle, 1.0)


I think if you don’t parse any float it assumes you want it cleaned all the way, at least it’s working on both my carwashes (vrp and essential mode)


That’s not how the natives work, you shouldn’t pass nothing in it just because it doesn’t crash. The natives actually require the right amount of parameters to be passed in. I’m sure it works because it looks like the elements built a check to catch missing values and replace them with some default/generic value.


Ok guys no luck. Heres what i have. As the way to do it is conflicted per person i have put them all together in one mega script.

    while true do  

    	local ped = GetPlayerPed(-1)
	local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
	local nveh = CreateVehicle(mhash, x,y,z+0.5, 0.0, true, false)

    	if IsPedSittingInAnyVehicle(ped) then
    		WashDecalsFromVehicle(vehicle, 1.0)
    		WashDecalsFromVehicle(GetVehiclePedIsUsing(GetPlayerPed(-1)), 1.0)
		SetVehicleDirtLevel(vehicle, 0.0)
		SetVehicleDirtLevel(nveh, 0.0)

i have tried both server and client side.

Any ideas?