I use the same button (MOUSE2) for rail and zoom, since I only use zoom with rail and haven't been able to find a suitable button. The way I've been playing for the last few years is that when you select rail, it goes to rail, and if you select rail again it zooms in. So basically you double click and it goes to rail and zooms in.

However there was a bug with this, which I've only noticed once i've started playing a lot of duel on aerowalk. If I die with rail out, then the next time i select rail it zooms in automatically.

It is a very minor problem, but still off putting in a tense game. So I have changed the zoomscript to work like this.

- Select rail, it selects rail
- select rail again and hold and it zooms in
- release it zooms out

if you die with rail out now, when you select rail again it only zooms in for a few milliseconds, so far less off putting before.

// Script
// *******
alias +holddown "+zoom ; vstr w7"
alias -holddown "-zoom ; vstr w7"

set railzoom "vstr w7 ; bind MOUSE2 +holddown"
set railn "bind MOUSE2 vstr railzoom; -holddown"

// normal weapons:
bind q "vstr railn ; vstr w6"

// rail bind
bind MOUSE2 "vstr railzoom"

UPDATE:

I have been playing around with using the cg_weaponconfig commands, however there appear to be some limitations with regards to the use of vstr, and I see that it only actions the commands once the weapon has changed (I want the weapon to zoom out instantly).

HOWEVER, since it automatically switches back to MG, I could use it to fix my previous script, which I have now done. I have moved all the weapon specific commands to cg_weaponconfig, and have added -zoom onto cg_weaponconfig_mg. The vstr scripts I am still running off the button so that they action instantly (and actually work, they don't seem to work very well on the cg_weaponconfig commands)

// Script
// *******
set fovin "+zoom"
set fovout "-zoom"

set railzoom "vstr railout"
set railin "vstr fovin ; set railzoom vstr railout"
set railout "vstr fovout ; set railzoom vstr railin"
set railn "vstr fovout ; set railzoom vstr railout"

set cg_weaponConfig_mg "cg_DrawCrosshair 2 ; cg_CrosshairSize 30;cg_playerlean 1 ; -zoom"
set cg_weaponConfig_other "cg_DrawCrosshair 9 ; cg_CrosshairSize 35;cg_playerlean 1"

bind r "weapon 2 ; vstr railn"
bind c "weapon 3 ; vstr railn"
bind MOUSE2 "weapon 7 ; vstr railzoom"

And everything is working as intended! Thanks guys!