There's an easier way.
Bind the ammo of your weapon to the variable you're wanting to use. You do this by adding the "bindammotovar" option to the gunspec of your weapon. So, if you're wanting to have the "energy" variable handle the ammunition of your weapon it would look like:
This will make it so the variable reflects the ammo the player has in that weapon, so if the player uses the weapon then the variable goes down. However, you will also be able to change the variable yourself to directly control how much ammo the player has.
Now, since the variable is automatically updated with the weapon's ammo amount, you won't need to worry about tracking it yourself. So you can pretty much eliminate all of your script except the first line (which is the line that recharges the weapon). The bonus of this is that when the variable reaches 0, the player's weapon really is out of ammo and so won't be able to fire anymore, but as soon as you add to that variable the player will have ammo again!
(For future reference, you CAN bind multiple weapons' ammos to the same variable and they will ALL share the same ammunition
)
On another note, Ply's Mod has entity timers, so it'd be best to use those instead of the global timer. Just replace "timergreater" with "etimergreater" and replace "timerstart" with "etimerstart". This prevents other scripts that use timers from interfering with this script's timer.
[*tears of joy* I still have great, unique features!
]
The one and only,