Gun-firing script...

I was wondering if it was possible to create a script that would, while I have pistols equipped, set the right mouse button to fire in addition to left, and when I have any other gun equipped switch it back to scope/alt fire.
Anyone got any ideas or any help?