Disable spawn of specified vehicles

Hi, how can I disable auto spawn of specified vehicles? I want disable emergency and military vehicles.

i don’t know, probably, look on the fivem forums

https://runtime.fivem.net/doc/natives/#_0x0FC2D89AC25A5814

Try using SetVehicleModelIsSuppressed

From the natives page:

seems to make the vehicle stop spawning naturally in traffic. Here’s an essential example:
VEHICLE::SET_VEHICLE_MODEL_IS_SUPPRESSED(GAMEPLAY::GET_HASH_KEY(“taco”), true);
god I hate taco vans
Confirmed to work? Needs to be looped? Can not get it to work.

Anyone have a working example for the OP?

1 Like
4 Likes

Yeah, that’s using ENABLE_DISPATCH_SERVICE to handle it. I can’t find any working snippet for SetVehicleModelIsSuppressed Which is unfortunate, as it would be nice to be able to handle vehicle spawns on a case by case basis instead of just wiping a whole group.

Yeah i was just answering OP’s question. Ive never tried that native it just looked interesting lol

Definitely an awesome find on the resource. I appreciate you posting it.

Where do I put this? Just make it a new resource or in the config?

I would look at something like this. It handles the existence of a vehicle in a loop. You can modify it to suit your needs but it shows you everything needed to detect a vehicle and then do something once found.

Is this vrp only?

It was developed with VRP in mind but is very easy to convert to ESX or strip it out entirely.

I’m new in lua coding and i made something like that:

function test()
    SetVehicleModelIsSuppressed(GetHashKey("police"), true) 
end
    setTimer ( test, 1000, 0 )

How make it work?

You can set SCENARIO_TYPES and remove from them the vehicle spawn.

Exemple:

2 Likes

:+1:Thank you for sharing. You are awesome! :slight_smile:

1 Like

I used your script and everything seems to be working excluding the trailers. They still seemed to be bugged at their spawn points. Does anyone have an idea how to fix this?

Any luck?

VRP_PLAYER > CLIENT.LUA

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(2000)
        local ped = PlayerPedId()
        local lastVehicle = 0
        local car = GetVehiclePedIsIn(GetPlayerPed(-1), false)
		
        if IsVehicleModel(car, GetHashKey("kosatka",_r)) then
			DeleteVehicle(car)
			SetVehicleModelIsSuppressed(GetHashKey("kosatka"), true) 
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )  
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("skylift",_r)) then
			DeleteVehicle(car)
			SetVehicleModelIsSuppressed(GetHashKey("kosatka"), true) 
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )  
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("avenger",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("cargoplane",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("bombushka",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("jet",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("volatol",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
			
		elseif IsVehicleModel(car, GetHashKey("kosatka",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("titan",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("tula",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("avenger2",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("blimp",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("blimp2",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("blimp3",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("alkonost",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
			
		elseif IsVehicleModel(car, GetHashKey("bmx",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")	

		elseif IsVehicleModel(car, GetHashKey("cruiser",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")	

		elseif IsVehicleModel(car, GetHashKey("fixter",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")

			
		elseif IsVehicleModel(car, GetHashKey("scorcher",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")

		elseif IsVehicleModel(car, GetHashKey("scorcher2",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")
		
		elseif IsVehicleModel(car, GetHashKey("scorcher3",_r)) then
			DeleteVehicle(car)
			Citizen.Trace("[MQCU]: VEICULO DELETADO" )
			TriggerServerEvent("NotifyGods","[MQCU]: VEICULO DELETADO, suspeito: ", "pega o id")	
			
			   
		end
    end
end)