MrSanchez 243 Posted July 9, 2015 Hey guys, Does anyone know how to retrieve an array of all muzzle attachments that can be fitted on a weapon? For mags I use: _mags=(getArray (configFile/"Cfgweapons"/(_array select 4)/"magazines")); // ignore the _array select 4 part, its part of my code) Now in CFGweapons, there is an entry (here an example for a MX) but I am not too sure how to access it. class WeaponSlotsInfo: WeaponSlotsInfo { class MuzzleSlot: SlotInfo { linkProxy = "\A3\data_f\proxies\weapon_slots\MUZZLE"; compatibleItems[] = {"muzzle_snds_h"}; }; class CowsSlot: CowsSlot { }; class PointerSlot: PointerSlot { }; }; Also, is there a way to retrieve an array of all muzzle attachments in the game? (Including modded ones?) My intentions is to add silencer variants to weapons that dynamically spawn in a weapon box or otherwise a seperate box with all silencers/muzzle attachment available in-game. Kind regards, Sanchez Share this post Link to post Share on other sites
Schatten 286 Posted July 9, 2015 (edited) _compatibleCowsItems = getArray (configFile >> "CfgWeapons" >> _typeName >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleitems"); _compatibleMuzzleItems = getArray (configFile >> "CfgWeapons" >> _typeName >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleitems"); _compatiblePointers = getArray (configFile >> "CfgWeapons" >> _typeName >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleitems"); _compatibleUnderBarrelItems = getArray (configFile >> "CfgWeapons" >> _typeName >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleitems"); _compatibleItems = _compatibleCowsItems + _compatibleMuzzleItems + _compatiblePointers + _compatibleUnderBarrelItems; or _compatibleItems = []; _weaponSlots = configFile >> "CfgWeapons" >> _typeName >> "WeaponSlotsInfo"; for "_i" from 0 to ((count _weaponSlots) - 1) do { _weaponSlot = _weaponSlots select _i; if (isClass _weaponSlot) then {_compatibleItems append (getArray (_weaponSlot >> "compatibleItems"))}; }; Edited July 9, 2015 by Schatten Some improvements Share this post Link to post Share on other sites
MrSanchez 243 Posted July 9, 2015 Yep, thanks a bunch ;) Kind regards, Sanchez Share this post Link to post Share on other sites
Schatten 286 Posted July 9, 2015 Unfortunately, second solution doesn't work properly. So use this improved first solution: _compatibleItems = []; _weaponSlots = configFile >> "CfgWeapons" >> _typeName >> "WeaponSlotsInfo"; {_compatibleItems append (getArray (_weaponSlots >> _x >> "compatibleItems"))} forEach ["CowsSlot", "MuzzleSlot", "PointerSlot", "UnderBarrelSlot"]; 2 Share this post Link to post Share on other sites
MrSanchez 243 Posted July 9, 2015 Thanks, I had it working after ur initial post...I was just a bit confused with the configFile command. Kind regards, Sanchez Share this post Link to post Share on other sites
ravenleg 37 Posted February 8, 2017 I've found that the above method typically works, but isn't 100% reliable for reasons I don't understand. I'm also trying to figure out the best way to access compatible accessories (muzzle attachments, optics, pointers, bipods) and the cleanest complete way is using a built-in function (bis_fnc_compatibleItems) that came with the Arsenal (and is in: Arma 3\Addons\functions_f_bootcamp.pbo\Inventory\fn_compatibleItems.sqf). It's annoying because it isn't documented anywhere. I only found about it by reading through the BIS_fnc_arsenal code in the same directory to see how the Arsenal itself computes compatible accessories. You can use it like this though (where it takes a class name string as an argument and returns an array of strings): _className = 'LMG_Mk200_F'; // You can put any weapon class name here _compatibleItems = _className call bis_fnc_compatibleItems; { _scope = str getNumber (configFile >> "CfgWeapons" >> _x >> 'scope'); _itemType = str (_x call bis_fnc_itemType); _itemName = _x; conWhite(_scope + " " + _itemType + " " + _itemName); // Log out to text file } forEach _compatibleItems; and, if you're running CUP and RHS, that will return this laundry list (for the LMG_Mk200_F in this case): Spoiler 2 ["Item","AccessoryMuzzle"] muzzle_snds_h 2 ["Item","AccessoryMuzzle"] muzzle_snds_h_khk_F 2 ["Item","AccessoryMuzzle"] muzzle_snds_h_snd_F 2 ["Item","AccessoryMuzzle"] muzzle_snds_H_MG 2 ["Item","AccessoryMuzzle"] muzzle_snds_H_MG_blk_F 2 ["Item","AccessoryMuzzle"] muzzle_snds_H_MG_khk_F 1 ["Item","AccessoryMuzzle"] muzzle_snds_H_SW 2 ["Item","AccessorySights"] rhs_acc_rakursPM 2 ["Item","AccessorySights"] rhs_acc_dh520x56 2 ["Item","AccessorySights"] rhsusf_acc_EOTECH 2 ["Item","AccessorySights"] rhsusf_acc_eotech_552 2 ["Item","AccessorySights"] rhsusf_acc_eotech_552_d 2 ["Item","AccessorySights"] rhsusf_acc_eotech_xps3 2 ["Item","AccessorySights"] rhsusf_acc_compm4 2 ["Item","AccessorySights"] rhsusf_acc_ACOG 2 ["Item","AccessorySights"] rhsusf_acc_ACOG2 2 ["Item","AccessorySights"] rhsusf_acc_ACOG3 2 ["Item","AccessorySights"] rhsusf_acc_ACOG_wd 2 ["Item","AccessorySights"] rhsusf_acc_ACOG_d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_sa 2 ["Item","AccessorySights"] rhsusf_acc_ACOG_USMC 2 ["Item","AccessorySights"] rhsusf_acc_ACOG2_USMC 2 ["Item","AccessorySights"] rhsusf_acc_ACOG3_USMC 2 ["Item","AccessorySights"] rhsusf_acc_ACOG_RMR 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_PIP 1 ["Item","AccessorySights"] rhsusf_acc_ACOG2_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG3_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_wd_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_d_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_sa_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_USMC_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG2_USMC_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG3_USMC_pip 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_RMR_PIP 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG2_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG3_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_wd_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_d_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_sa_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_USMC_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG2_USMC_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG3_USMC_3d 1 ["Item","AccessorySights"] rhsusf_acc_ACOG_RMR_3d 2 ["Item","AccessorySights"] rhsusf_acc_ELCAN 2 ["Item","AccessorySights"] rhsusf_acc_ELCAN_ard 1 ["Item","AccessorySights"] rhsusf_acc_ELCAN_3d 1 ["Item","AccessorySights"] rhsusf_acc_ELCAN_ard_3d 1 ["Item","AccessorySights"] rhsusf_acc_ELCAN_PIP 1 ["Item","AccessorySights"] rhsusf_acc_ELCAN_ard_PIP 2 ["Item","AccessorySights"] rhsusf_acc_SpecterDR 1 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_3d 2 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_A 1 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_A_3d 1 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_CX_3D 2 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_D 2 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_OD 1 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_D_3D 1 ["Item","AccessorySights"] rhsusf_acc_SpecterDR_OD_3D 2 ["Item","AccessorySights"] rhsusf_acc_anpvs27 2 ["Item","AccessorySights"] rhsusf_acc_anpas13gv1 2 ["Item","AccessorySights"] rhsusf_acc_M2A1 2 ["Item","AccessorySights"] rhsusf_acc_ACOG_MDO 2 ["Item","AccessorySights"] optic_Nightstalker 2 ["Item","AccessorySights"] optic_tws 2 ["Item","AccessorySights"] optic_tws_mg 2 ["Item","AccessorySights"] optic_NVS 2 ["Item","AccessorySights"] optic_SOS 2 ["Item","AccessorySights"] optic_SOS_khk_F 2 ["Item","AccessorySights"] optic_MRCO 2 ["Item","AccessorySights"] optic_Arco 2 ["Item","AccessorySights"] optic_Arco_ghex_F 2 ["Item","AccessorySights"] optic_Arco_blk_F 2 ["Item","AccessorySights"] optic_aco 2 ["Item","AccessorySights"] optic_ACO_grn 2 ["Item","AccessorySights"] optic_aco_smg 2 ["Item","AccessorySights"] optic_ACO_grn_smg 2 ["Item","AccessorySights"] optic_hamr 2 ["Item","AccessorySights"] optic_Hamr_khk_F 2 ["Item","AccessorySights"] optic_Holosight 2 ["Item","AccessorySights"] optic_Holosight_smg 2 ["Item","AccessorySights"] optic_Holosight_blk_F 2 ["Item","AccessorySights"] optic_Holosight_khk_F 2 ["Item","AccessorySights"] optic_Holosight_smg_blk_F 2 ["Item","AccessorySights"] optic_DMS 2 ["Item","AccessorySights"] optic_DMS_ghex_F 2 ["Item","AccessorySights"] optic_LRPS 2 ["Item","AccessorySights"] optic_LRPS_ghex_F 2 ["Item","AccessorySights"] optic_LRPS_tna_F 2 ["Item","AccessorySights"] optic_AMS 2 ["Item","AccessorySights"] optic_AMS_khk 2 ["Item","AccessorySights"] optic_AMS_snd 2 ["Item","AccessorySights"] optic_KHS_blk 2 ["Item","AccessorySights"] optic_KHS_hex 2 ["Item","AccessorySights"] optic_KHS_old 2 ["Item","AccessorySights"] optic_KHS_tan 2 ["Item","AccessorySights"] optic_ERCO_blk_F 2 ["Item","AccessorySights"] optic_ERCO_khk_F 2 ["Item","AccessorySights"] optic_ERCO_snd_F 2 ["Item","AccessorySights"] CUP_optic_AN_PAS_13c2 2 ["Item","AccessorySights"] CUP_optic_AN_PAS_13c1 2 ["Item","AccessorySights"] CUP_optic_HoloBlack 2 ["Item","AccessorySights"] CUP_optic_HoloWdl 2 ["Item","AccessorySights"] CUP_optic_HoloDesert 2 ["Item","AccessorySights"] CUP_optic_CompM4 2 ["Item","AccessorySights"] CUP_optic_SUSAT 2 ["Item","AccessorySights"] CUP_optic_Eotech533 2 ["Item","AccessorySights"] CUP_optic_ACOG 2 ["Item","AccessorySights"] CUP_optic_CWS 2 ["Item","AccessorySights"] CUP_optic_AN_PVS_10 2 ["Item","AccessorySights"] CUP_optic_CompM2_Black 2 ["Item","AccessorySights"] CUP_optic_CompM2_Woodland 2 ["Item","AccessorySights"] CUP_optic_CompM2_Woodland2 2 ["Item","AccessorySights"] CUP_optic_CompM2_Desert 2 ["Item","AccessorySights"] CUP_optic_RCO 2 ["Item","AccessorySights"] CUP_optic_RCO_desert 2 ["Item","AccessorySights"] CUP_optic_ElcanM145 2 ["Item","AccessorySights"] CUP_optic_Eotech533Grey 2 ["Item","AccessorySights"] CUP_optic_LeupoldMk4_CQ_T 2 ["Item","AccessorySights"] CUP_optic_ELCAN_SpecterDR 2 ["Item","AccessorySights"] CUP_optic_SB_11_4x20_PM 2 ["Item","AccessorySights"] CUP_optic_ZDDot 2 ["Item","AccessorySights"] CUP_optic_MRad 2 ["Item","AccessorySights"] CUP_optic_TrijiconRx01_desert 2 ["Item","AccessorySights"] CUP_optic_TrijiconRx01_black 2 ["Item","AccessorySights"] CUP_optic_AN_PVS_4 2 ["Item","AccessorySights"] CUP_optic_Elcan 2 ["Item","AccessorySights"] CUP_optic_Elcan_reflex 2 ["Item","AccessoryPointer"] rhs_acc_2dpZenit_ris 2 ["Item","AccessoryPointer"] rhs_acc_perst1ik_ris 2 ["Item","AccessoryPointer"] rhs_acc_perst3 2 ["Item","AccessoryPointer"] rhsusf_acc_wmx 2 ["Item","AccessoryPointer"] rhsusf_acc_M952V 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15A 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_light 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_top 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_h 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_light_h 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_top_h 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15side 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_bk 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_bk_light 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_bk_top 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_bk_h 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_bk_light_h 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_bk_top_h 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15side_bk 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_wmx 2 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_wmx_light 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_wmx_h 1 ["Item","AccessoryPointer"] rhsusf_acc_anpeq15_wmx_light_h 2 ["Item","AccessoryPointer"] acc_flashlight 2 ["Item","AccessoryPointer"] acc_pointer_IR 2 ["Item","AccessoryPointer"] CUP_acc_ANPEQ_15 2 ["Item","AccessoryPointer"] CUP_acc_ANPEQ_2 2 ["Item","AccessoryPointer"] CUP_acc_Flashlight 2 ["Item","AccessoryPointer"] CUP_acc_Flashlight_wdl 2 ["Item","AccessoryPointer"] CUP_acc_Flashlight_desert 2 ["Item","AccessoryPointer"] CUP_acc_ANPEQ_2_camo 2 ["Item","AccessoryPointer"] CUP_acc_ANPEQ_2_desert 2 ["Item","AccessoryPointer"] CUP_acc_ANPEQ_2_grey 2 ["Item","AccessoryPointer"] CUP_acc_XM8_light_module 2 ["Item","AccessoryPointer"] CUP_acc_LLM 2 ["Item","AccessoryBipod"] rhs_acc_harris_swivel 2 ["Item","AccessoryBipod"] rhsusf_acc_harris_bipod 2 ["Item","AccessoryBipod"] bipod_01_F_snd 2 ["Item","AccessoryBipod"] bipod_01_F_blk 2 ["Item","AccessoryBipod"] bipod_01_F_mtp 2 ["Item","AccessoryBipod"] bipod_02_F_blk 2 ["Item","AccessoryBipod"] bipod_02_F_tan 2 ["Item","AccessoryBipod"] bipod_02_F_hex 2 ["Item","AccessoryBipod"] bipod_03_F_blk 2 ["Item","AccessoryBipod"] bipod_03_F_oli 2 ["Item","AccessoryBipod"] bipod_01_F_khk 2 ["Item","AccessoryBipod"] CUP_bipod_Harris_1A2_L 2 ["Item","AccessoryBipod"] CUP_bipod_VLTOR_Modpod I included in the printout each item's scope, because only items with scope = 2 will actually be usable in the game. Also, the function bis_fnc_itemType is useful for categorizing what gets returned (since it returns all compatible items, not just a particular type). 1 Share this post Link to post Share on other sites
serena 151 Posted February 8, 2017 Fn_Gear_CompatibleAttachments = { //0 - muzzle, 1 - optic, 2 - pointer, 3 - bipod private _wpn = _this select 0; private _asi = _this select 1; private _asn = ["MuzzleSlot", "CowsSlot", "PointerSlot", "UnderBarrelSlot"] select _asi; private _cfa = configfile >> "CfgWeapons" >> _wpn >> "WeaponSlotsInfo" >> _asn >> "compatibleItems"; private _res = nil; if (isClass _cfa) then { _res = configProperties [_cfa, "isNumber _x"] select {getNumber _x > 0} apply {configName _x}; } else { if (isArray _cfa) then { _res = getArray _cfa; }; }; _res }; // Usage: // var _compatibleAttachmentsArray = [weaponClassString, attachmentTypeNumber] call Fn_Gear_CompatibleAttachments; // where attachmentTypeNumber: 0 - muzzle, 1 - optic, 2 - pointer, 3 - bipod 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted October 3, 2018 This is my ex: //________________ add weapon's compatible attachments ________________ _weapons = "Your_weapon_classname"; _MuzzleSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems"); _Muzzle = selectRandom _MuzzleSlot; _CowsSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems"); _Optic = selectRandom _CowsSlot; _PointerSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems"); _Pointer = selectRandom _PointerSlot; _UnderBarrelSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems"); _UnderBarrel = selectRandom _UnderBarrelSlot; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _Muzzle;}; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _Optic;}; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _Pointer;}; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _UnderBarrel;}; 1 1 Share this post Link to post Share on other sites
Vandeanson 1677 Posted October 5, 2018 On 4.10.2018 at 1:26 AM, GEORGE FLOROS GR said: This is my ex: //________________ add weapon's compatible attachments ________________ _weapons = "Your_weapon_classname"; _MuzzleSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems"); _Muzzle = selectRandom _MuzzleSlot; _CowsSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems"); _Optic = selectRandom _CowsSlot; _PointerSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems"); _Pointer = selectRandom _PointerSlot; _UnderBarrelSlot = getArray (configFile / "CfgWeapons" >> _weapons >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems"); _UnderBarrel = selectRandom _UnderBarrelSlot; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _Muzzle;}; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _Optic;}; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _Pointer;}; if (floor (random 10) < 4) then {_this addPrimaryWeaponItem _UnderBarrel;}; sweet that worked well =) thanks! 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted October 5, 2018 Thanks Vandeanson ! By the way this new avatar is cool ! Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted October 5, 2018 Just now, GEORGE FLOROS GR said: This is for the handguns : //________________ add _Side_Weapon's compatible attachments ________________ _Side_Weapon_MuzzleSlot = getArray (configFile / "CfgWeapons" >> _Side_Weapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems"); _Side_Weapon_Muzzle = selectRandom _Side_Weapon_MuzzleSlot; _Side_Weapon_CowsSlot = getArray (configFile / "CfgWeapons" >> _Side_Weapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems"); _Side_Weapon_Optic = selectRandom _Side_Weapon_CowsSlot; _Side_Weapon_PointerSlot = getArray (configFile / "CfgWeapons" >> _Side_Weapon >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems"); _Side_Weapon_Pointer = selectRandom _Side_Weapon_PointerSlot; if (floor (random 10) < 4) then {_this addHandgunItem _Side_Weapon_Muzzle;}; if (floor (random 10) < 4) then {_this addHandgunItem _Side_Weapon_Optic;}; if (floor (random 10) < 4) then {_this addHandgunItem _Side_Weapon_Pointer;}; Share this post Link to post Share on other sites
Vandeanson 1677 Posted October 6, 2018 1 hour ago, GEORGE FLOROS GR said: Thanks Vandeanson ! By the way this new avatar is cool ! Thanks ;)) 1 Share this post Link to post Share on other sites