Just make sure final value is not < 0
set_pev(i, pev_armorvalue, floatmax(YOUR_CALCULATION, 0.0))
Anyway, if it is for cs, you should use cs_set_user_armor, so you can set armortype to 0 when armorvalue is 0, and if, before calcultion, armor amount is > 0 but armortype is 0 (can happen if a bad plugin is used), do nothing.