How can I turn off viewmodels for certain weapons?

I know that I can turn off the viewmodels of all weapons of a specific class by typing r_drawviewmodel "0"
into the cfg file of that class, but how can I (with or without scripts) turn the viewmodels off for one weapon, but on for another?
e.g. I want my viewmodel to be on for my flamethrower and melee weapon for the pyro, but I want my shotgun's viewmodel off (as it helps me aim better). Is there any way I can do this?
In response to Austin's answer, I thought I'd post my entire cfg for my Pyro, to see if there are any conflictions:
cl_autoreload 1
unbind mouse3
//Secondary weapon
alias +secondary "slot2"
alias -secondary "slot1"
//Melee weapon
alias +melee "slot3"
alias -melee "slot1"
//Binds
bind "mouse5" "+melee;r_drawviewmodel 1"
bind mwheelup "slot1;r_drawviewmodel 1"
bind mwheeldown "slot2;r_drawviewmodel 0"**
There is a bit in there about when I hold mouse5, I switch to melee, and, upon release, I switch back to my primary weapon, but I don't know if this is relevant.
Best Answer
Adding
bindtoggle r r_drawviewmodel
to autoexec.cfg will allow you to press r (or whatever key you choose) in-game to toggle viewmodels on and off at will.
Pictures about "How can I turn off viewmodels for certain weapons?"



What is the command to turn off Viewmodels tf2?
Go to advanced settings then enable the minmode viewmodel. You're pretty rich though, how did you get VAC ban? There's an option in the Advanced Settings "Use minimized viewmodels". Tick that option and you're good to go.TF2 Tutorial: How to turn off viewmodels for specific weapons/slots/classes
More answers regarding how can I turn off viewmodels for certain weapons?
Answer 2
Make a toggle viewmodel:
Put in your class name.cfg
:
bindtoogle [key] "r_drawviewmodel 0 1"
Then, change the [key] to a key of course and when you press your key, it will turn on and off viewmodels.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: George Milton, Gustavo Fring, Erik Mclean, ANTONI SHKRABA