I had experimented with those random weapon scripts before and I also used a bunch of ifs. Then someone told me that this wouldn't be completely random because it could check the value of rndwep2 several times before something matches. With each if (= rndwep2 x), the value of rndwep2 is being randomized. The solution is
[SELECT ALL] Code:
rndwep2 = (rnd 4)
nextprimary (+ $rndwep2 2)