Delete car after a while (like rent car)

Hey guys,
as my title says. I want to delete a car i have created after 30 minutes - 1 hour, but i dont know how to do this. Here ist the code, where the car gets created. Maybe you guys can tell me, how to trigger a event which lets the car despawn?

ESX.Game.SpawnVehicle(boat, spawnPoints, 201.2251, function(vehicle)
		local playerPed   = GetPlayerPed(-1)
		
		SetVehicleOnGroundProperly(vehicle)
		SetVehicleEngineOn(vehicle, true, true, true)
		SetVehicleHasBeenOwnedByPlayer(vehicle, true)
		TaskWarpPedIntoVehicle(playerPed,  vehicle,  -1)
		SetEntityAsMissionEntity(vehicle, true, true);
		--SetModelAsNoLongerNeeded(vehicle)
	end)

Greeting
Happy

Here is someone that just posted something like this, but as they uploaded a .rar file and NOT the source code, I really can’t tell you if it works or is written well. I can’t be bothered downloading it and extracting it, just to find it sucks. But here is the link anyway.

And looking at your code, I would say that you can’t set the exact time that it gets deleted with my solution, but you can remove the functions that tell it NOT to delete it and then let the game automatically delete it when it runs a cleanup, periodically.

ESX.Game.SpawnVehicle(boat, spawnPoints, 201.2251, function(vehicle)
	SetVehicleOnGroundProperly(vehicle)
	SetVehicleEngineOn(vehicle, true, true, true)
	TaskWarpPedIntoVehicle(GetPlayerPed(-1),  vehicle,  -1)
end)

When player rents a car, create a new thread, wait x ms, then delete the entity.

I have fixed the download. Thanks for sharing though!