Select entities by color and do something to them?

Im trying to do that if an entity is transparent (like alpha 190 or less), a halo is drawn around it. (This is being run clientside btw) and i’ve tried many ways to do it, by using the GetAll() and then v:GetColor() but for some reason it doesn’t work. I tried printing the v:GetColor() and it printed me, instead of a color table, something like.

table: 0x546e9e48
table: 0x4392df30
table: 0x55b3f1a0
table: 0x54c0a6c8
table: 0x55af5a18
table: 0x5588c300
table: 0x473b7c68

which I supose is something like a “table ID”?

I also thought about using traces but the trace result table doesn’t return anything like the color.

Something I thought about is doing a code in all entities that is like:

if self.GetColor() == Color(0,0,0,190) then
[draw the halo]

But I don’t know how to do that, and i didn’t find any answers online or in the wiki, on how to run code in all the entities (which is something I’m sure it’s not that hard to do because It’s pretty useful)

Here is the code of the getall and getcolor.

hook.Add("Think", "colorGet", function()
	for k,v in pairs(ents.GetAll()) do 
		if v:GetColor() == Color(0,0,0,190) then
			halo.Add(ents.GetAll(), Color(255,0,0,255), 5, 5,30, true, true )

This is for my server because it’s annoying when someone gets the color tool and uses it to make something invisible,to help with the administration of my server, and I also had the chance to try to code, but I got stuck with this.

EDIT: Solved it, just did some messing around with tables, here’s the code:

wantHolo = {} 

transparencia = 180

hook.Add("Think", "colorGet", function()
	enties = ents.FindByClass("prop_physics")
	for k,v in pairs(enties) do 
		if v:GetColor().a <= transparencia then
		if v:GetColor().a > transparencia then

halo.Add(wantHolo, Color(255,0,0,255), 5, 5,30, true, true )

You could try

if v:GetColor().a <= 190 then

For some reason, even if there aren’t any entities with that color the halo is drawn everywhere (even though this is because in the halo I target all entities)

That would be because you are adding a halo to all entities.


This code means add a halo to every entity.

Please don’t add Halos on the Think hook, add them on this hook: