Code:
var ammo_reload = minv(
    ammo_left,          // Maximum is ammo_left, so we can't reload bullets we don't have
    30 - ammo_current); // Calculate missing ammo in weapon
ammo_left -= ammo_reload;
ammo_current += ammmo_reload;


Should do the stuff you want


Visit my site: www.masterq32.de