1. Make sure your inventory is completely full (I had a Mosin in my rifle slot when doing this) so that the "take M4 into hands" option shows up when you try to pick it up.
2. Pick up an M4 so that your character is holding it in their hands.
3. Log out from the server you're on, and when you get to the server list, click cancel to get back to the start screen.
4. Click "change server" but choose the same server that you just logged out from. Once you get back in, the M4 you were holding in your hands have moved to a temporary spot on the right side of your inventory, below everything else that you carry. There will also be an M4 on the ground where you're standing.
5. Drag and drop the M4 on the right hand side of your inventory, into your "in hands" slot.
6. Log out again as per step 3 above.