Check if Vehicle has any decal other than clan decals

Well, you want to use for a car wash script right? Why not just use:

float GET_VEHICLE_DIRT_LEVEL(Vehicle vehicle);

I believe you don’t want to use it because it probably does not take into account blood splatters?

AFAIK, the native directory by FiveM (the one you’re using) uses nativeDB to get some of the natives. It then adds it’s own natives and updates some of the names. So, using the FiveM documentation is recommended.

So, have you tried using other values for the second parameter in the DOES_VEHICLE_HAVE_DECAL? The documentation posits that it could be a “decal index” and 0 may be for clan decals. You should be able to test this using the ADD_DECAL native. If not, you could try and use the IS_DECAL_ALIVE native to check (I don’t know what it does but, it sounds like its checking to see if the decal is on a vehicle).

Edit: I’ve moved this to #development:scripts as this seems a more appropriate category

@Seenko yes that’s right, blood splatters are decals and that function returns a float from 0 to 15.0 that represents the dust the car has or how dirty it is, doesn’t take in account the snow, mud or blood

@Havoc i’ve tried passing the second parameter of that function as 0, 1, false and true and the result was always false

void WASH_DECALS_FROM_VEHICLE(Vehicle vehicle, float p1);

Sadly it does not return anything after “washing” tho… If i did return something that would be a way to check if any decal was washed just for 0.0001 :thinking: But it’s void :pensive:

@Seenko didn’t try, but according to one of my script release comments it doesn’t matter weather you parse 1.0 or 100.0

That comment suggests that the max value for that parameter is 1.0, you could try with a value lower than that (it’s a float so try 0.0001), either way that’s a void function and shouldn’t return anything and I don’t think there is a way to contravention that…

@Seenko that’s true …

And also, not all decal functions are related to vehicles, only the ones that mention it on it’s name, the decals could be blood splatters on the ground and walls.

then i guess i’m stuck am i right ? because either i’m really blind or i don’t see any function that might suggest that it checks for decals and takes a parameter Vehicle other than DoesVehicleHaveDecal() but we already know that doesn’t work

I’m sorry, I’m having a little trouble understanding what you mean here. Are you saying you passed 0/1 as the parameter? If so, try using the decal index. For example, of you wanted to check if the vehicle has mud on it, you would pass “splatters_mud” (1020) to it and check the return value.

Edit: @TheSparta if you’re wanting to clean a vehicle, couldn’t you just use the SET_VEHICLE_DIRT_LEVEL native?

dirt isn’t a decal, but i’ll try parsing the 2nd parameter of DoesVehicleHaveDecal() as a decal id now since i’m already home

He wants to know if the vehicle is actually dirty, not just using the dirt level. For example, you shoot a ped near the vehicle and the blood will splatter in the vehicle, that does not change the vehicle’s dirt lever but is actually a decal in the vehicle, so if he checks only for the dirt level the vehicle will come out as clean even tho there is blood dripping from its door.

splatterDecals = {
	1010, -- splatters_blood
	1015, -- splatters_blood_dir
	1017, -- splatters_blood_mist
	1020, -- splatters_mud
	1030, -- splatters_paint
	1040, -- splatters_water
	1050, -- splatters_water_hydrant
	1110  -- splatters_blood2
}
-- later --

function es_carwash_checkfordecals()
	vehiclehasdecals = false
	for i = 0, #splatterDecals do
		result = DoesVehicleHaveDecal(GetVehiclePedIsUsing(GetPlayerPed(-1)), splatterDecals[i])
		if result == true then
			vehiclehasdecals = true
		end
	end
	return vehiclehasdecals
end

--when key is pressed --

hasdecals = es_carwash_checkfordecals()
TriggerServerEvent('es_carwash:checkmoney', GetVehicleDirtLevel(GetVehiclePedIsUsing(GetPlayerPed(-1),false)), hasdecals)

this would work if the second parameter of DoesVehicleHaveDecal() was an index right ?

Seems like it, yes, what was the returned value for each decal index?

well it didn’t clean my car when it only had blood splatters (i cleaned it first and then ran over some npcs) so i guess it returned false and only works for clan decals xD

just to clear everthing i’ll give you my server side script aswell

RegisterServerEvent('es_carwash:checkmoney')
AddEventHandler('es_carwash:checkmoney', function (userVehicleDirtLevel, userVehicleHasDecals)
	TriggerEvent('es:getPlayerFromId', source, function (user)
		if userVehicleDirtLevel > 1.0 or userVehicleHasDecals == true then	-- this is the magical if that would make the script continue if the dirt level was greater than 1.0 or the car had decals
			if enableprice == true then
				userMoney = user.getMoney()
				if userMoney >= price then
					user.removeMoney(price)
					TriggerClientEvent('es_carwash:success', source, price)
				else
					moneyleft = price - userMoney
					TriggerClientEvent('es_carwash:notenoughmoney', source, moneyleft)
				end
			else
				TriggerClientEvent('es_carwash:free', source)
			end
		else
			TriggerClientEvent('es_carwash:alreadyclean', source)
		end
	end)
end)

either that or my decal ids are wrong … but i got them from here

What is the output for this

function es_carwash_checkfordecals()
	vehiclehasdecals = false
	for i = 0, #splatterDecals do
		result = DoesVehicleHaveDecal(GetVehiclePedIsUsing(GetPlayerPed(-1)), splatterDecals[i])
		print(string.format("%i: %t",splatterDecals[i],result))
	end
end

it will be false but i’ll do it anyways …

well my client console said result was nil it didn’t even run string.format because of it

bad argument #2 to 'format' (number expected, got nil)