What you need to look into is casting. Give all your weapons the same base class for common functionality and then cast to the specific weapon if it has specific functionality.
If you don’t need common functionality then skip the first part, but essentially when a cast fails then you know that that variable doesn’t represent the weapon you tested for.
Or on the other hand if it succeeds then you know the player has the weapon you need.