If you don't have fixed positions for the weapons like 0=fist 1=pistol... you could set the array x to 0 and when you get new weapon you can use push back on the array.
When your weapon selection is greater or equal the array width (note that array width will count also the first 0) set selection to 0 and when your selection is less than 0 set selection to array width-1.