Check the number of entities

Is it possible to check the number of entities of a certain class there are in a map? Like checking how many prop_physics there are?

I don’t know if this will, I can’t test anything right now. But you could try this:
[lua] ent=ents.FindByClass(“class”) print(table.Count(ent) ) [/lua]

If that doesn’t work (Which I don’t think it will) you could always do this

[lua]
function CheckEntites(entname)
local num=0
for k,v in pairs (ents.GetAll()) do
if v:GetClass()=entname then
num=num+1
end end

return num

end [/lua]

Something like that maybe. I had to type that in the browser by the way.

Why wouldn’t the first one work?

Although as it will be a numerically indexed table, table.Count isn’t needed.

[lua]#ents.FindByClass( “class here” )[/lua]

Should work fine.