Okay, help
mag1="M16"
nmag1="M4"
mag2="M4"
nmag2="M16"
prigun1="M16"
nprigun1="M4"
prigun2="M4"
nprigun2="M16"
_player = _this select 0
hint format ["%1",magazines _player]
_magazines = magazines _player
_newmags = []
_i = 0
_j = count _magazines
#loop
?(_magazines select _i) == mag1 : _newmags set [_i,nmag1]
?(_magazines select _i) == mag2 : _newmags set [_i,nmag2]
_i = _i + 1
?(_i > _j) : goto "replace"
goto "loop"
#replace
_weapon = primaryweapon _player
_newgun = ""
_player removeweapon primaryweapon _player
_player removemagazines _weapon
?(_weapon) == prigun1 : _newgun = nprigun1
?(_weapon) == prigun2 : _newgun = nprigun2
hint format ["%1\n%2\n%3\n%4",_magazines,_newmags,_weapon,_newgun]
"_player addmagazine _x" foreach _newmags
_player addweapon _newgun
_player selectweapon _newgun
exit
I have the above code (big thanks to TheCaptain) and it works flawlessly. What it does is it switches the M16 for the XM-177, and all M16 mags for XM-ones. I've also tried switching an AK74 for an AK47.
Now, when I try this with my own addon however (which is the reason I want/need the script), it doesn't work. What happens is it doesn't remove the current mags, so they stay there (doubling the amount of mags).
Now, I don't know why this is, but I had a theory that it's because my mag-names differ from the weapon-names. I.E the M16 is called the M16 and the M16 mags are called M16, but mine don't work like that.
So I was wondering if anyone could like, show me to where the problem lies, or write a better script, I'd be very much pleased.