Entity - Check if in player inventory

When a player respawns, every item in his inventory (for instance in sandbow the physgun, crowbar and others) are created entities.
I have a script that when an entity spawns, it gets deleted after 10 seconds if in a table of tracked entities.
However, I don’t want entities in a player’s inventory to be removed. Is there a way to check if the entity is inside a player’s inventory?


Thanks! But if the player drops the weapon with /drop (basewars gamemode) is he still the owner of the entity?

EDIT: When an entity is bought, it seems that the owner is already the player, even if not in his inventory. Is there any other way to check if an entity isn’t in a player’s inventory?
EDIT 2: I decided to make the entities not solid instead of removing them, that will stop the problems with the weapons colliding with each other and causing lag. The only problem I have now is that they clip through the ground too.
EDIT 3: Tried using the SetCollisionGroup function and put it to COLLISION_GROUP_WORLD but it still collides with other entities.

[editline]3rd August 2017[/editline]

local EntsToNoCollide = 
     ["weapon_crowbar"] = true

hook.Add("OnEntityCreated", "NoCollideEntities", function (ent)
	if ( not(ent:IsValid() and EntsToNoCollide[ent:GetClass()]) ) then 
	print("Entity Created: " .. ent:GetClass())
end )

When I spawn crowbars, they still collide with each other, but the docs say that entities with the “COLLISION_GROUP_INTERACTIVE_DEBRIS” collision group don’t collide with each other.

Solved! Using a “ShouldCollide” hook seems like your best bet if anybody has that problem.