How to make a gun only pickupable by a certain class

im making a gamemode in fretta where you pick a class like a medic or sniper and i want to make better guns to be kind of placed on the map for them to find but i dont want a medic picking up a gun for a demo class. Also i would like it if it removed the weapon its slot is in ex. the gun in row 5 slot 3 would be replaced by it. any help is appreciated = )