Finding entities of a certain class and running a function.

Looking for the most efficient way to find all “money_printer” class entities within a 300 unit radius, and drawing text above each of them.

:smiley:

[lua]local dist = 300
hook.Add(“PostDrawOpaqueRenderables”, “MoneyPrinter”, function()
for _, v in ipairs(ents.FindByClass(“money_printer”)) do
local pos = v:GetPos()
if (LocalPlayer():GetPos() - pos):LengthSqr() < dist^2 then
local ang = (EyePos()-pos):Angle()
cam.Start3D2D(pos, Angle(ang.p, ang.y, 0), 1)
– Draw stuff here
cam.End3D2D()
end
end
end)[/lua]

This might work, untested.