well, the script should request all weapon images on the server, and make a variable for every weapon.
then, when a shot is fired, it should request the weapon image of the weapon, find the right variable that belongs to the weapon image, then do -1 to the variable and then check if the variable isn't 0.
If it is 0, it should delete the weapon from your hand (if you want that, otherwise it should make it not fire anymore).
Then you also need a new output event, that should be called setweaponammo/addweaponammo and it should have the output parameters of the different weapons and a box for how much ammo it should have.
Sorry I can't give you a script of the thing above (because I actually suck at scripting), but you can go to coding help and ask there.
also don't know how to do this with automatic weapons (like minigun or such).