Halo on All Entities, Can I specify one?

I’ve developed a few entities and I want them to have a specified colour of halo on them when they are within the players corsshair.
In my cl_init.lua, I have
[lua]hook.Add( “PreDrawHalos”, “AddHalos_”, function()
halo.Add( {traceHalo.Entity}, Color( 160, 0, 192 ), 1, 1, 10 )
end )
local entityTable
hook.Add(“Think”, “_t”, function()
if CLIENT then
local ply = LocalPlayer()
traceHalo = util.TraceLine( {
start = ply:GetShootPos(),
endpos = ply:GetShootPos() + ply:GetAimVector()*100,
filter = ply
} )
end

end )
[/lua]
I want it so I can define a class file, example ent_mytest
And when that entity is spawned, only it will have the halo, nothing else.

In cl_init, you could do something like this:



function ENT:Initialize( )
  hook.Add( "PreDrawHalos", self, self.PreDrawHalos )
end

function ENT:PreDrawHalos( )
  local tr = { }
  local pl = LocalPlayer( )

  tr.start = pl:GetShootPos( )
  tr.endpos = tr.start + pl:GetAimVector( ) * 100
  tr.filter = pl

  tr = util.TraceLine( tr )
  
  if tr.Entity == self then
    halo.Add( { self }, Color( 160, 0, 192 ), 1, 1, 10 )
  end
end

This way each instance of your entity will check on its own.

Thanks again Kogitsune, this was exactly what I needed! :dance: