Jump to content
bl2ck dog

Replace few types of magazines with single one?

Recommended Posts

Good day, community, I do need some help.


I'm using RHS for my survival scenario. After quite a break, I returned to Arma and found out that they've added integrated large number of different ammunition types to the weapon configs  - great job, actually, love the depth of it.

But since you couldn't merge different types of ammo in one magazine (using Outlaw MagRepack), constantly scavenging and swapping weapons, after just an hour of gameplay, I ended up with like 20 different full and half-empty AK mags, which also clogged scroll menu.


Basically, I would like to revert it back to single type of magazine (say "rhs_30Rnd_545x39_AK") while keeping whole range of weapons .


So, first idea was to make a script that constantly roams through player's inventory and replaces "wrong" types of mags with the one I need.

waitUntil {!isNull player};
private ["_magazinesAmmo","_needReplace","_ammoCount"];

while {true} do {
  sleep 1;
  _magazinesAmmo = magazinesAmmo player;
    sleep 1;
    _needReplace = "rhs_30Rnd_545x39_7N10_AK" in _x;
    _ammoCount = _x select 1;
    if (_needReplace) then {
      player removeMagazine "rhs_30Rnd_545x39_7N10_AK"; 
      player addMagazine ["rhs_30Rnd_545x39_AK",_ammoCount]; 
    hint format ["%1\n%2\n%3",_x,_needReplace,_ammoCount];

  } forEach _magazinesAmmo;

With that I managed to replace one type of mag with another. But then I kinda get lost in arrays and their nesting.

Also I couldn't find the way to remove specific mag (with selected number of ammo), so problem might be with removing/adding magazine with wrong number of ammo.


What I need is to get it working with arrays of pairs like:


Maybe, there's another way, like changing CfgMagazines somehow, so all the RHS weapons simply spawn with one type of magazine each, but I've currently have no idea how to make that.

Any help or advice appreciated. Thank you.

Share this post

Link to post
Share on other sites

You could use the take eventhandler and simply check if the item taken is a compatible mag and do your swap.


player addEventHandler ["Take", {
	params ["_unit", "_container", "_item"];
	_compatibleMags = ["someClassnames"];
	if (_item in _compatibleMags) then {
      _unit removeMagazine "rhs_30Rnd_545x39_7N10_AK"; 
      _unit addMagazine ["rhs_30Rnd_545x39_AK",_ammoCount]; 

Just an untested quick example, adjust as needed.

This will check if the item is in the compatible mag array and switch it out.



  • Like 2

Share this post

Link to post
Share on other sites

Thanks Grumpy Old Man, works like a charm.


//                                                                                               //
//  B2 Mag Replacer Script                                                                       //
//  by Bl2ck Dog                                                                                 //
//                                                                                               //
//  Replaces vanilla and RHS 30-round 5.45x39, 5.56x45 and 7.62x39 mags with one of each kind    //
//  Big thanks and repsect to Grumpy Old Man from BIS forums!                                    //
//                                                                                               //
//  Add to initPlayerLocal.sqf:                                                                  //
//  [] execVM "scripts\b2_magReplacer.sqf";                                                      //
//                                                                                               //
waitUntil {!isNull player};

player addEventHandler ["Take",{
	params ["_unit","_container","_item","_wrongMags545","_wrongMags762","_wrongMags556","_allWrongMags","_rightMag"];
	_v     = 1.01; //version
	_debug = false;
	_wrongMags545  = [

	_wrongMags762 = [

	_wrongMags556  = [

  _allWrongMags = _wrongMags545 + _wrongMags762 + _wrongMags556;
	if (_item in _allWrongMags) then {
    if (_item in _wrongMags545) then {_rightMag="rhs_30Rnd_545x39_7N10_camo_AK"};
    if (_item in _wrongMags762) then {_rightMag="rhs_30Rnd_762x39mm"};
    if (_item in _wrongMags556) then {_rightMag="rhs_mag_30Rnd_556x45_M855A1_PMAG"};
    _unit removeMagazine _item;
    _unit addMagazine _rightMag;
    if (_debug) then {hint format ["B2 Mag Replacer Script v%1\n\n%2\nreplaced with\n%3",_v,_item,_rightMag]};


Two minor issues so far:

1) if weapon has no mag and you pick "wrong" one from the ground - it goes directly in the weapon (I guess, another EH is used)

2) always gives you full mag, no matter how many rounds was in one on the ground


Still, works perfect and solves initial problem.

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now