Clean Car on spawn or disable car dirt?


#1

Hello,

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:

GetVehicleDirtLevel(GetVehiclePedIsIn(GetPlayerPed(-1),false))

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


#2

just use this resource to wash cars


#3

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)
      end

      local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
      local vehicleClass = GetVehicleClass(vehicle)
      local nveh = CreateVehicle(mhash, x,y,z+0.5, 0.0, true, false)
      SetVehicleOnGroundProperly(nveh)
      SetEntityInvincible(nveh,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
      SetVehicleHasBeenOwnedByPlayer(nveh,true)

      if not cfg.vehicle_migration then
        local nid = NetworkGetNetworkIdFromEntity(nveh)
        SetNetworkIdCanMigrate(nid,false)
      end

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

      SetModelAsNoLongerNeeded(mhash)

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

#4

Could this be the better working version do you think?

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

SetVehicleDirtLevel(GetVehiclePedIsUsing(GetPlayerPed(-1)))

#5

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


#6

SetVehicleDirtLevel(nveh(GetPlayerPed(-1)))

Is that it then?


#7

@HarryCatraz

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


#8

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.


#9

@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)


#10

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)


#11

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)


#12

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.


#13

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.

Citizen.CreateThread(function()
    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
    		Citizen.Wait(1)
    		WashDecalsFromVehicle(vehicle, 1.0)
    		WashDecalsFromVehicle(GetVehiclePedIsUsing(GetPlayerPed(-1)), 1.0)
		SetVehicleDirtLevel(GetVehiclePedIsUsing(GetPlayerPed(-1)))
		SetVehicleDirtLevel(vehicle, 0.0)
		SetVehicleDirtLevel(nveh, 0.0)
	end
    end
end)

i have tried both server and client side.

Any ideas?