The script Gruntage quoted is
by Blip. The problem you are having stems from the 'crate-like' behaviour of objects where magazines are automatically reloaded when weapons are taken. You can test it for yourself on crates, vehicles, or, as shown in the script, weaponholders. BUT IT DOES NOT APPLY TO DEAD BODIES!
Place a soldier far out of the way. Name him ColdDeadHands and set his health to zero. Remove all his weapons.
IF YOU WANT, edit his Init line to load him with a weapon and magazines that the player can swap with straight away,
for example:
removeAllWeapons this
removeAllWeapons this; this addMagazine "HK"; this addMagazine "HK"; this addMagazine "HK"; this addWeapon "HK"
In the init line of the player write:
player addAction ["Switch Weapons", "WEK_SwitchWeapons.sqs"]
if (primaryWeapon ColdDeadHands == "") then {goto "PutWeapon"}
; Swap Weapons
player action ["Take Weapon", ColdDeadHands, 0,0, (primaryWeapon ColdDeadHands)]
exit
; Put Weapon (because there was nothing to swap)
#PutWeapon
if (primaryWeapon player == "") then {hint "No weapons to swap between."; exit}
player action ["Drop Weapon", ColdDeadHands, 0,0, (primaryWeapon player)]
~1
ColdDeadHands action ["Take Weapon", player, 0,0, (primaryWeapon player)]
exit
Edit: updated the script for situations when the player has discarded one weapon and hence has nothing to swap with - in this circumstance the weapon is transferred to ColdDeadHands and the player is free to pick up something else. Although you can take weapons from dead bodies, you can't put them; they have to go via the empty crate.
Edit 2: But then again, dead bodies can take weapons directly from you. Spooky! This means an intervening crate is no longer required.
Edit 3: Realised that using a civilian with only 4 magazine slots might cause a problem - use a soldier instead.
Edit 4: Used primaryWeapon to select ColdDeadHands' weapon as well as the player's - now more consistent and hopefully a smidgen faster.