Vehicle Health

Hello. Is there a way to set the health of a vehicle? Not an entity vehicle like SCars but an actual vehicle using the jeep base. Thanks.

Well it depends what you want to happen once the health is 0.

i just want it removed it doesnt need to be anything fancy

I use this
[lua]
DefaultVehicleHP = 40
hook.Add(“EntityTakeDamage”, “VehicleHPHook”, function( ent, dmginfo )
if not ent:IsVehicle() then
return
end
if not ent:Health() then
ent:SetHealth(DefaultVehicleHP)
end
//print(dmginfo:GetDamageType())
//if dmginfo:GetDamageType() == 0 then return end
if not dmginfo:GetDamageType() == DMG_BULLET or dmginfo:GetDamageType() == DMG_BLAST then return end
ent:SetHealth(ent:Health() - dmginfo:GetDamage())
if ent:Health() < 1 and not ent.Destroyed then
ent.Destroyed = true
ent:SetColor(255,255,255,255)
ent:SetMaterial(“models/rendertarget”)
local ExplodeTime = math.random(5,19)
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:SetKeyValue(“iMagnitude”, “250”)
explosion:Spawn()
explosion:Fire(“explode”, “”, 0)
explosion:Fire(“kill”, “”, 0)
timer.Simple(.1, 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)
[/lua]

okay so i saw that online somewhere but i was confused about where to put it




local V = { 	
				// Required information
				Name = "Vehicle", 
				Class = "prop_vehicle_jeep",
				Category = Category,

				// Optional information
				Author = "Danny",
				Information = "Vehicle",
				Model = "models/vehicle/vehicle.mdl",
				
				KeyValues = {
								vehiclescript	=	"scripts/vehicles/vehicle.txt"
							}
			}

list.Set( "Vehicles", "Vehicle", V )