Does somebody know how i get this script to work with sickness cars?

This code will only work for the standart jeep.

[lua]
local DefaultVehicleHP = 250
local DeafaultCleanupTime = 20
hook.Add(“EntityTakeDamage”, “VehicleHPHook”, function( ent, inflictor, attacker, amount, dmginfo )
if not ent:IsVehicle() then
return
end
ent.HP = ent.HP or DefaultVehicleHP
ent.HP = ent.HP - dmginfo:GetDamage()*10000
print(ent.HP)
if ent.HP <= 0 and not ent.Destroyed then
ent.Destroyed = true
ent:SetColor(0,0,0,255)
local ExplodeTime = math.random(5,10)
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", "100")
		explosion:Fire("Explode", 0, 0)	
		if ent:GetDriver():IsPlayer() then
			ent:GetDriver():Kill()
		end
		if ent:GetPassenger():IsPlayer() then
			ent:GetPassenger():Kill()
		end
		if not ent then return end
		ent:Remove()
	end)
end

end)
[/lua]

Got a link to the addon?

svn : http://subversion.assembla.com/svn/SicknessModel/

All of the vehicles there are just the jeep with different models, I guess you could try this:

[lua]
local DefaultVehicleHP = 250
local DeafaultCleanupTime = 20
hook.Add(“EntityTakeDamage”, “VehicleHPHook”, function( ent, inflictor, attacker, amount, dmginfo )
if ent:GetClass() != “prop_vehicle_jeep” then – seems odd I know, but if you look in the addon all the vehicles are prop_vehicle_jeep with a different model
return
end
ent.HP = ent.HP or DefaultVehicleHP
ent.HP = ent.HP - dmginfo:GetDamage()*10000
print(ent.HP)
if ent.HP <= 0 and not ent.Destroyed then
ent.Destroyed = true
ent:SetColor(0,0,0,255)
local ExplodeTime = math.random(5,10)
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", "100")
        explosion:Fire("Explode", 0, 0) 
        if ent:GetDriver():IsPlayer() then
            ent:GetDriver():Kill()
        end
        if ent:GetPassenger():IsPlayer() then
            ent:GetPassenger():Kill()
        end
        if not ent then return end
        ent:Remove()
    end)
end

end)[/lua]

If that doesn’t work, could you be a bit specific as to how it doesn’t work? I noticed you have a debug print in there, does that print? What does it print?

Ahh it works now many thinks,
The print said in console everytime it was shot the hp.
Diddent notice that all cars had same class me is fail.
COOKIE FOR YOU :smiley: