Stop NPCs from dropping weapons

I am looking for a way to stop NPCs from dropping weapons or remove the dropped weapons. I already attempted to remove the dropped weapons but the way I did it does’t work as it also removes the weapons from NPCs that are still alive. Ideas/Suggestions/Help would be appreciated (and yes, I did search for solutions for this problem before posting :wink: )

My attempt:



function GM:OnEntityCreated ( ent )
	if ( ent == NULL) or ( ent == nil ) then return end
	if ( ent:GetClass() == "weapon_smg1" or ent:GetClass() == "weapon_ar2" or ent:GetClass() == "weapon_shotgun" )  then
		if ent:IsValid() and ( ent:GetOwner() != NULL ) then
			SafeRemoveEntityDelayed( ent,10 )
		end
	end
end


I think you’d have to edit a key value for NPCs themselves. Look up citizens on valve wiki

Thanks BFG for the tip, I found a solution :slight_smile:
It works when you set this when spawning the combine soldier:


 ent:SetKeyValue( "spawnflags", 8192 )