SWEP Fire Rate - on the fly

So I want to change a SWEP’s fire rate on the fly, and not in the SWEP script. Is it possible to make a function to change it like this?

SetNextPrimaryFire(x) is what I’ve been told, and tried to use but I’ve never, ever made a SWEP so I’m clueless.

I think you could make a convar and then set the firerate to it’s value.