Comparing two tables for one entry

I have two tables that were made. One table was made using ents.FindInSphere(), the other was made using ents.FindByModel(). I am trying to find one value that is in both tables.

So, I will search the entire map for an entity with the model of “models/props_c17/FurnitureDrawer003a.mdl”, and then I will search 300 units around my ‘Detection’ entity for all entities. I get a table of all entities around my Detector and a table of all entities with the model “models/props_c17/FurnitureDrawer003a.mdl”

How do I look to see if there is an entity within 300 units of my Detector that has the model “models/props_c17/FurnitureDrawer003a.mdl” ???

Thank you in advance!

just do a for loop with an if statement inside:



for k, v in pairs( ents.FindInSphere( entity, 300) ) do
  if v:GetModel() == "model/path/here" then
    --do stuff
  end
end




for k,v in pairs( ents.GetAll() ) do
     if v:GetModel() == "models/props_c17/FurnitureDrawer003a.mdl" then
          print("Found Item | Entity Class = "..v:GetClass().." | x = "..v:GetPos().x.." | y = "..v:GetPos().y.." | z = "..v:GetPos().z)
     end
end
for k,v in pairs( ents.FindInSphere("Detector_Entity", 300) ) do
     if v:GetModel() == "models/props_c17/FurnitureDrawer003a.mdl" then
          print("Found Item Near Detector | Entity Class = "..v:GetClass().." | x = "..tostring(v:GetPos().x).." | y = "..tostring(v:GetPos().y).." | z = "..tostring(v:GetPos().z))
     end
end

I’ve tried that already, cabbiethefirst.

But thank you very much because I now notice my mistake. I had the for loop, and then an inclusion, and after the inclusion I had it return false.

so every time it returned false.

I meant to have an else statement in there.