Switching to a static weapon using keyboard input

I am making an FPS and I want to make an option to switch the current weapon to a machine gun which is static so to take its control a player should go near to it and click a spcific keyboard button.

I’m familiar with weapon switching but I have no idea how to make it active only in the specific area (in this case, around the machine gun)?
I’m using C# for scripting, if that’s important.

Thanks.

Basically you only need to check if weapon is near when player click.
There is many techniques to verify if a object is near, one way is to use Physics.OverlapSphere.

http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html

You will get with something like:

// non tested sample code :P
if (Input.GetButton("e")) {
  for (var c : Collider in Physics.OverlapSphere(transform.position, maxDistance)) {
     if (c.gameObject.tag == 'weapon') {
       // assign weapon to player, disable player moviment, etcc
       break;
     }
  }
}