Well you should have a variable like Wequip that is set to 1 when you get the gun, to 0 when you don´t have it and to when is unnequiped, so you have a function managing this variable like

Code:
while(1)//for ever or until a break
{
 switch(Wequip)//acording to Wequip
 {
  case 0://if its 0
   // put here the commands
   break;
  case 1://if its 0
   // put here the commands
   break;
  case 2://if its 0
   // put here the commands
   break;
 }
}


if you have many weapons you can use an array like Wequip[x] where x is the number of the weapons


CAUTION :The content above could blow your mind