Vehicle Health (TDM/SCars)

I was wondering if anyone knew how to make a script where if the vehicle took enough damage it would explode and become inactive for a short period of time, maybe 60 seconds.

pretty soon this will be out and i cant wait it will do it plus even more features: http://vcmod.net/

Scars already have that future.
There is even a variable where you can decide the removetime.

Sam, where can I find this?


DefaultVehicleHP = 50
DeafultCleanupTime = 180
hook.Add("EntityTakeDamage", "VehicleHPHook", function( ent, dmginfo )
	if not ent:IsVehicle() then
		return 
	end
	if not ent.HP then
		ent.HP = DefaultVehicleHP
	end
	ent.HP = ent.HP - dmginfo:GetDamage() * 100
	if ent.HP <= 0 and not ent.Destroyed then
		ent.Destroyed = true
		ent:SetColor(Color(0,0,0,255))
		local ExplodeTime = math.random(5,30)
		ent:Ignite(ExplodeTime,100)
		--[[if ent:GetDriver():IsPlayer() then
			ent:GetDriver():ExitVehicle()
		end
		if ent:GetPassenger():IsPlayer() then
			ent:GetPassenger():ExitVehicle()
		end
		--]]
		timer.Simple(ExplodeTime, function()
			if not ent then return end
			local explosion = ents.Create("env_explosion")
			explosion:SetPos(ent:GetPos())
			explosion:SetOwner(attacker)
			explosion:Spawn()
			explosion:SetKeyValue("iMagnitude", "1000")
			explosion:Fire("Explode", 0, 0)	
			if ent:GetDriver():IsPlayer() then
				ent:GetDriver():Kill()
			end
			if ent:GetPassenger():IsPlayer() then
				ent:GetPassenger():Kill()
			end
			timer.Simple(DeafultCleanupTime, function()
				if not ent then return end
				ent:Remove()
			end)
		end)
	end
end)

hook.Add("CanPlayerEnterVehicle", "ExplodedVehicles", function(ply, vehicle, role)
	if vehicle.Destroyed then 
		return false
	end
end)

I didn’t make this, but here you go…