ENT:OnTakeDamage does nothing?

Hello, humans. Here is my code:


if redbase == nil then
redbase = ents.Create ("prop_physics")
end
redbase:SetPos (Vector(-2070, -535, -465))
redbase:SetAngles (Angle(0, -90, 0))
redbase:SetModel ("models/props_interiors/VendingMachineSoda01a.mdl")
redbase:Spawn ()
redbase:GetPhysicsObject():EnableMotion (false)

function redbase:OnTakeDamage (dmgtable) print ("hallo") end

… and it never prints “hallo”. Feel so lonely. Changed model to explosive barrel - it exploded, but without saying “hallo”. Please, show me the mistake.
P.S. I was damaging it with crowbar and pistol.

that kind OnTakeDamage works only on scripted ents, to make your script work correctly, you have to create a global hook with EntityTakeDamage, add a var inside redbase to verify it inside your hook and then perform your print (“hallo”)

It only works on Scripted Entities, not on any random entity.

Are there any other suitable hooks? I mean, the destructible entities some have sort of health, so the game should register when the entity is being attacked.

[editline]18th January 2017[/editline]

How can I make the scripted entity? Can you advise any tutorials, please?