Damage doesnt register on entity.

I am trying to make a destroyble barricade. I cant get it to detect the damage that the entity wouldve taken. Heres my client ,server, and shard files.

Shared


/*---------------------------------------------------------------------------
This is an example of a custom entity.
---------------------------------------------------------------------------*/
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Money Printer"
ENT.Author = "DarkRP Developers and <enter name here>"
ENT.Spawnable = false
ENT.AdminSpawnable = false

function ENT:SetupDataTables()
end


Client


/*---------------------------------------------------------------------------
This is an example of a custom entity.
---------------------------------------------------------------------------*/
include("shared.lua")

function ENT:Initialize()
end

function ENT:Draw()
	self:DrawModel()
end

function ENT:Think()
end


Server


/*---------------------------------------------------------------------------
This is an example of a custom entity.
---------------------------------------------------------------------------*/
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

local PrintMore
function ENT:Initialize()
	self:SetModel("models/props_c17/consolebox01a.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	local phys = self:GetPhysicsObject()
	phys:Wake()
	self.sound:PlayEx(1, 100)
end

function ENT:OnTakeDamage(dmg)
	print("test")
	self.damage = (self.damage or 100) - dmg:GetDamage()
	self:SetNWInt("health",self.damage)
	return	
end


Try this
add to Initialize -



self:SetNWInt("health", 100)


your OnTakeDamage hook -



function ENT:OnTakeDamage(dmg)
	print("test")
	self:SetNWInt("health", self:GetNWInt("health") - dmg:GetDamage())	
end


works for me

All the stuff you were talking about was handled from another file, shown below. What you showed didnt work for me either though.

CODE FOR WHAT I SAID ABOVE


barricadeTypes = {
{"models/props_c17/FurnitureCouch002a.mdl", 100,1},
{"models/props_c17/concrete_barrier001a.mdl",250,1}, 
{"models/props_c17/display_cooler01a.mdl",300,1},
{"models/props_borealis/bluebarrel001.mdl",50,1},
{"models/props_c17/furnitureStove001a.mdl",200,1}
}

colors = {
	{255,0,0,255},
	{0,255,0,255},
	{0,0,255,255},
	{255,255,0,255},
	{255,0,255,255},
	{0,255,0,255},
	{0,255,255,255},
	{255,255,255,255},
	{0,0,0,255}
}

function createBarricade(owner,type,colorr,colorg,colorb,x,y,z,rx,ry,rz)
local barricade = ents.Create( "barricade" )
barricade:SetModel(barricadeTypes[type][1])
barricade:SetPos(Vector(x,y,z))
barricade:SetAngles(Angle(rx,ry,rz))

    	barricade:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
		barricade:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
		barricade:SetSolid( SOLID_VPHYSICS )         -- Toolbox
		
		local phys = barricade:GetPhysicsObject()
		if phys:IsValid() then
			phys:Wake()
		end
	if(colorr==nil and colandg==nil and colorb==nil)then 
	local random = math.random(0,#colors)
	barricade:SetColor(colors[random][1],colors[random][2],colors[random][3],255)
	else
	barricade:SetColor(colorr,colorg,colorb,255)
	end
barricade:SetNWEntity("owner",owner)
barricade:SetNWInt("health",barricadeTypes[type][2])
barricade.damage = barricadeTypes[type][2]
barricade:SetNWInt("maxhealth",barricadeTypes[type][2])
barricade.maxHealth = barricadeTypes[type][2]
end



hook.Add( "GravGunPickupAllowed", "checkIfOwner", function(ply,ent)
if(ply==ent:GetNWEntity("owner"))then
return true
else
return false
end
end )

createBarricade(nil,1,255,255,255,332.962982 ,350.273773, -83.968796,0,0,0)

bymp