Hi there,
perhaps this will help:
_wpns = ["m4a1","m16a4","m24","m107","m240","m249"];
_wcount = count _wpns;
_rdm = round (random _wcount);
_wpn = _wpns select _rdm;
_this addweapon format ["%1", _wpn];
Not sure if this can be shortened or simplified here and there... Written from memory, ye kno?
Btw, what you see above is to be put into a script. If you want to put that stuff directly into a unit's init-line, make sure to remove all the _'s (as in, "wpns" instead of "_wpns", etc.). Should then work.
Good day,
mr_book