• ENT:OnTakeDamage does nothing?
    3 replies, posted
Hello, humans. Here is my code: [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[/CODE] ... 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.
[QUOTE=gonzalolog;51685003]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")[/QUOTE] 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] [QUOTE=Robotboy655;51685009]It only works on Scripted Entities, not on any random entity.[/QUOTE] How can I make the scripted entity? Can you advise any tutorials, please?
Sorry, you need to Log In to post a reply to this thread.