Make a simple glow around a certain whitelist of entities?

Hey all, i’m trying to figure out where to start with this and if someone already has this created?



if (SERVER) then

	AddCSLuaFile()

else

	local whitelist = {"insert_entity_class_here", "add_extra_if_necessary"} -- For example, a prop's class is "prop_physics".

	hook.Add("PreDrawHalos", "Halo Whitelist", function()
		for _, v in pairs(ents.GetAll()) do -- Run a loop through all entities on the server. (uuughhh)
			if v:GetClass() == whitelist[v] then -- Get the entities' class' and compare them to the whitelist table's strings.
				halo.Add(v, Color(0, 255, 0), 1, 1, 1) -- Add a green halo to the entity if it passes the 'if' statement above.
			end
		end
	end )

end


Stick that in lua/autorun, I’ve commented the code to the best of my abilities.
Not tested.

If you want to get the class of an entity in-game, run ‘sv_allowcslua 1’ in console and use the command ‘lua_run_cl print( LocalPlayer():GetEyeTrace().Entity:GetClass() )’ whilst looking at the entity you want to add. Make sure to return ‘sv_allowcslua 0’ afterwards, unless you keep it on for other purposes.

However, this is not optimized. The halos will render no matter wherever the client is, consider this a base for you to try and understand how LUA works.

I made christmas tree’s flash with halos a couple few seasons back and the fps lag was not ammusing…

Thank you! Thats exactly what I needed and I can code off that :smiley: