Entity with Hook

Hey,

For my Tripmine, i used the following setup:

[LUA]
function ENT:Initialize()
hook.Add(“PostDrawOpaqueRenderables”,“tripmine” … self:EntIndex(),function()
–draw stuff
end)
end

function ENT:OnRemove()
hook.Remove(“PostDrawOpaqueRenderables”,“tripmine” … self:EntIndex())
end
[/LUA]

But sometimes, people can see theses Hooks after the Round finished (TTT)
Or some people can’t see the drawed stuff at all.

Is there a better approach?

Instead of adding a hook for each entity just have 1 hook that loops through your entities. Then when your entities are gone there is nothing to loop through / no matching entities.

Assuming what your doing has to be done inside that hook and can’t just go in ENT:Draw or ENT:DrawTranslucent