Check what the current weapon/attachment is.

Hi,
how could I check what the category (primary_ar or secondary_pistol for example) of the weapon you're currently holding is?
And also how do I check if said current weapon has a certain attachment?
Like for example "if the currently equipped weapon has a flashlight(or any other attachment I want to check with its id) on it then do this ..."
I don't want to do this like "if the primary has a flashlight then do this ... " because then it would also apply to the secondary which doesn't have the attachment.
Oh and I want to check it ingame, not in the menu/inventory.
Replies