bl2ck dog 80 Posted January 13, 2019 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: [ [["wrong_mag_calA_01","wrong_mag_calA_02"],"right_mag_calA"], [["wrong_mag_calB_01","wrong_mag_calB_02"],"right_mag_calB"] ]; 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
Grumpy Old Man 3545 Posted January 13, 2019 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. Cheers 2 Share this post Link to post Share on other sites
bl2ck dog 80 Posted January 16, 2019 Thanks Grumpy Old Man, works like a charm. Spoiler /*///////////////////////////////////////////////////////////////////////////////////////////////// // // // 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 = [ "30Rnd_545x39_Mag_F", "30Rnd_545x39_Mag_Green_F", "30Rnd_545x39_Mag_Tracer_F", "30Rnd_545x39_Mag_Tracer_Green_F", "rhs_30Rnd_545x39_7N10_2mag_AK", "rhs_30Rnd_545x39_7N10_2mag_camo_AK", "rhs_30Rnd_545x39_7N10_2mag_desert_AK", "rhs_30Rnd_545x39_7N10_2mag_plum_AK", "rhs_30Rnd_545x39_7N10_AK", //"rhs_30Rnd_545x39_7N10_camo_AK", "rhs_30Rnd_545x39_7N10_desert_AK", "rhs_30Rnd_545x39_7N10_plum_AK", "rhs_30Rnd_545x39_7N22_AK", "rhs_30Rnd_545x39_7N22_camo_AK", "rhs_30Rnd_545x39_7N22_desert_AK", "rhs_30Rnd_545x39_7N22_plum_AK", "rhs_30Rnd_545x39_7N6_AK", "rhs_30Rnd_545x39_7N6_green_AK", "rhs_30Rnd_545x39_7N6M_AK", "rhs_30Rnd_545x39_7N6M_green_AK", "rhs_30Rnd_545x39_7N6M_plum_AK", "rhs_30Rnd_545x39_7U1_AK", "rhs_30Rnd_545x39_AK_green", "rhs_30Rnd_545x39_AK_plum_green" ]; _wrongMags762 = [ "30Rnd_762x39_Mag_F", "30Rnd_762x39_Mag_Green_F", "30Rnd_762x39_Mag_Tracer_F", "30Rnd_762x39_Mag_Tracer_Green_F", //"rhs_30Rnd_762x39mm", "rhs_30Rnd_762x39mm_89", "rhs_30Rnd_762x39mm_bakelite", "rhs_30Rnd_762x39mm_bakelite_89", "rhs_30Rnd_762x39mm_bakelite_tracer", "rhs_30Rnd_762x39mm_bakelite_U", "rhs_30Rnd_762x39mm_polymer", "rhs_30Rnd_762x39mm_polymer_89", "rhs_30Rnd_762x39mm_polymer_tracer", "rhs_30Rnd_762x39mm_polymer_U", "rhs_30Rnd_762x39mm_tracer", "rhs_30Rnd_762x39mm_U" ]; _wrongMags556 = [ "30Rnd_556x45_Stanag", "30Rnd_556x45_Stanag_Tracer_Green", "30Rnd_556x45_Stanag_Tracer_Red", "30Rnd_556x45_Stanag_Tracer_Yellow", "rhs_mag_30Rnd_556x45_M200_Stanag", "rhs_mag_30Rnd_556x45_M855_PMAG", "rhs_mag_30Rnd_556x45_M855_PMAG_Tan", "rhs_mag_30Rnd_556x45_M855_PMAG_Tan_Tracer_Red", "rhs_mag_30Rnd_556x45_M855_PMAG_Tracer_Red", "rhs_mag_30Rnd_556x45_M855_Stanag", "rhs_mag_30Rnd_556x45_M855_Stanag_Tracer_Red", //"rhs_mag_30Rnd_556x45_M855A1_PMAG", "rhs_mag_30Rnd_556x45_M855A1_PMAG_Tan", "rhs_mag_30Rnd_556x45_M855A1_PMAG_Tan_Tracer_Red", "rhs_mag_30Rnd_556x45_M855A1_PMAG_Tracer_Red", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", "rhs_mag_30Rnd_556x45_Mk262_PMAG", "rhs_mag_30Rnd_556x45_Mk262_PMAG_Tan", "rhs_mag_30Rnd_556x45_Mk262_Stanag", "rhs_mag_30Rnd_556x45_Mk318_PMAG", "rhs_mag_30Rnd_556x45_Mk318_PMAG_Tan", "rhs_mag_30Rnd_556x45_Mk318_Stanag" ]; _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