Undeceived 392 Posted June 10, 2018 Hi guys, is there a way to (code-wise) add a compatible weapon attachment - here: suppressor - to the currently selected gun? In my case it's an AK from the CUP mod (if this is relevant at all). Thank you very much! Share this post Link to post Share on other sites
HazJ 1289 Posted June 10, 2018 You might be able to get it from config or try: https://community.bistudio.com/wiki/BIS_fnc_compatibleItems Loop through suppressors and add it. There is a simpler way I'm sure but can't help right now, will look later if I get chance! 1 Share this post Link to post Share on other sites
7erra 629 Posted June 10, 2018 _cfgArray = getArray (configfile >> "CfgWeapons" >> _yourWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems"); _supressor = [nil, selectRandom _cfgArray] select (count _cfgArray > 0); _unit addPrimaryWeaponItem _supressor; 2 1 Share this post Link to post Share on other sites
Undeceived 392 Posted June 10, 2018 35 minutes ago, 7erra said: _cfgArray = getArray (configfile >> "CfgWeapons" >> _yourWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems"); _supressor = [nil, selectRandom _cfgArray] select (count _cfgArray > 0); _unit addPrimaryWeaponItem _supressor; Thanks a lot, 7erra! Much appreciated. At first it didn't work, but then I checked the config and found what to change -> the part in the "WeaponSlotsInfo". In vanilla it is "MuzzleSlot", in CUP it's "CUP_EastMuzzleSlotAK". This means that the code is not totally "universal", but in my case it's absolutely sufficient as there are no Western weapons in the corresponding mission. Thanks again! The code looks like this now: _cfgArray = getArray (configfile >> "CfgWeapons" >> (currentWeapon player) >> "WeaponSlotsInfo" >> "CUP_EastMuzzleSlotAK" >> "compatibleItems"); _supressor = [nil, selectRandom _cfgArray] select (count _cfgArray > 0); player addPrimaryWeaponItem _supressor; 2 Share this post Link to post Share on other sites
HazJ 1289 Posted June 10, 2018 You could check for CUP_ prefix. If CUP then do CUP_EastMuzzleSlotAK or whatever and if vanilla, etc... Do something else. Use find command to search for prefix. Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted June 11, 2018 As @HazJ suggested, it's best to use BIS_fnc_compatibleItems if you want to make sure that all compatible suppressors are returned, since, as you already noticed, some mods have their own muzzle class and won't inherit from the vanilla class. This will always add the first compatible suppressor if there are compatible ones: _muzzles = [currentweapon player,"muzzle"] call BIS_fnc_compatibleItems; _muzzles params [["_suppressor",""]]; _unit addPrimaryWeaponItem _suppressor; You might end up with non matching combinations in terms of color though (at least for vanilla weapons). Cheers 3 Share this post Link to post Share on other sites
gokitty1199 225 Posted June 11, 2018 22 hours ago, Undeceived said: Thanks a lot, 7erra! Much appreciated. At first it didn't work, but then I checked the config and found what to change -> the part in the "WeaponSlotsInfo". In vanilla it is "MuzzleSlot", in CUP it's "CUP_EastMuzzleSlotAK". This means that the code is not totally "universal", but in my case it's absolutely sufficient as there are no Western weapons in the corresponding mission. Thanks again! The code looks like this now: _cfgArray = getArray (configfile >> "CfgWeapons" >> (currentWeapon player) >> "WeaponSlotsInfo" >> "CUP_EastMuzzleSlotAK" >> "compatibleItems"); _supressor = [nil, selectRandom _cfgArray] select (count _cfgArray > 0); player addPrimaryWeaponItem _supressor; make it universal with a switch statement kind of like so using the author _devName = getText (configFile >> "cfgWeapons" >> _weaponName >> "author"); then do a switch on _devName _muzzleSlot = ""; switch (_devName) do { case "CUP": {_muzzleSlot = "whatever"; case "Bohemia Interactive": {_muzzleSlot = "yea that"}; }; Share this post Link to post Share on other sites