Jump to content
Airwolf

Whitelisting Weapons in Arsenal using "_availableWeapons" - not working

Recommended Posts

Hi,

 

i'm creating a whitelisted arsenal, and everything has been working great so far such as headgear, uniforms, backpacks, etc.

 

But as soon as I get to the weapons, nothing shows up.

 

I've added as a test:

 

_availableWeapons = [
"uns_m1garand",
"uns_m14"
];
 
And these items are not showing. What am I doing wrong?
 
Thank you.

Share this post


Link to post
Share on other sites

Gonna need to see more code than that to tell what you're doing wrong.  I can tell you that you've properly created a locally available array of two strings however.

Share this post


Link to post
Share on other sites

This is the full script.

//Init stuff
_crate = _this select 0;
["AmmoboxInit",[_crate,false,{true}]] spawn BIS_fnc_arsenal;

//Lists of items to include
_availableHeadgear = [
	"UNS_Boonie_OD",
	"UNS_Boonie_OD2",
	"UNS_Boonie_ODF",
	"UNS_Boonie_ODP",
	"UNS_Boonie_DK",
	"UNS_Boonie_DKF",
	"UNS_Boonie_ERDL",
	"UNS_Bandana_OD",
	"UNS_Bandana_OD2",
	"UNS_USMC_Cover",
	"UNS_M1_9A",
	"UNS_M1_8A",
	"UNS_M1_7A",
	"UNS_M1_6A",
	"UNS_M1_5A",
	"UNS_M1_4A",
	"UNS_M1_3A",
	"UNS_M1_2A",
	"UNS_M1_1A",
	"UNS_M1_17",
	"UNS_M1_16",
	"UNS_M1_15",
	"UNS_M1_14",
	"UNS_M1_13",
	"UNS_M1_12",
	"UNS_M1_11",
	"UNS_M1_10",
	"UNS_M1_9",
	"UNS_M1_8",
	"UNS_M1_7",
	"UNS_M1_6",
	"UNS_M1_5",
	"UNS_M1_4",
	"UNS_M1_3",
	"UNS_M1_2",
	"UNS_M1_1",
	"UNS_M1_AFT",
	"UNS_M1_MP",
	"UNS_M1_SP",
	"UNS_M1_PBR",
	"UNS_M1_1V1",
	"UNS_M1_1V2",
	"UNS_M1_1V1N",
	"UNS_M1_1V3",
	"UNS_M1_1V4",
	"UNS_M1_1V5",
	"UNS_M1_1V6",
	"UNS_M1_1V7",
	"UNS_M1_1V8",
	"UNS_M1_1RM",
	"UNS_TC_1",
	"UNS_TC_2",
	"UNS_HP_Helmet",
	"UNS_JP_Helmet",
	"UNS_JP_Helmet2",
	"UNS_Headband_OD",
	"UNS_Headband_OD2",
	"UNS_Headband_ED",
	"UNS_Headband_BK",
	"H_Bandanna_gry",
	"H_Bandanna_blu",
	"H_Bandanna_cbr",
	"H_Bandanna_khk_hs",
	"H_Bandanna_khk",
	"H_Bandanna_sgg",
	"H_Bandanna_sand",
	"H_Bandanna_surfer",
	"H_Bandanna_surfer_blk",
	"H_Bandanna_surfer_grn",
	"H_Bandanna_camo",
	"usm_bdu_boonie_blk",
	"usm_bdu_boonie_blu",
	"usm_bdu_boonie_erdl",
	"usm_bdu_boonie_gry",
	"usm_bdu_boonie_odg",
	"usm_bdu_boonie_portliz",
	"usm_bdu_boonie_tgrstp",
	"usm_bdu_boonie_wdl",
	"usm_bdu_cap_blk",
	"usm_bdu_cap_blu",
	"usm_bdu_cap_erdl",
	"usm_bdu_cap_gry",
	"usm_bdu_cap_odg",
	"usm_bdu_cap_portliz",
	"usm_bdu_cap_tgrstp",
	"usm_bdu_cap_wdl",
	"usm_bdu_8point_blk",
	"usm_bdu_8point_blu",
	"usm_bdu_8point_erdl",
	"usm_bdu_8point_gry",
	"usm_bdu_8point_odg",
	"usm_bdu_8point_portliz",
	"usm_bdu_8point_tgrstp",
	"usm_bdu_8point_wdl",
	"usm_bdu_8point_wdl_m",
	"usm_bdu_blk",
	"usm_bdu_odg",
	"usm_bdu_w",
	"usm_bdu_w_m",
	"H_Watchcap_blk",
	"rhs_beanie_green",
	"H_Watchcap_cbr",
	"rhs_beanie",
	"H_Watchcap_camo",
	"H_Watchcap_khk",
	"H_Beret_blk",
	"H_Beret_02",
	"H_Beret_Colonel",
	"H_Booniehat_khk_hs",
	"H_Booniehat_khk",
	"H_Booniehat_oli",
	"H_Booniehat_tan",
	"rhsgref_Booniehat_alpen",
	"rhs_Booniehat_m81",
	"H_Cap_blk",
	"H_Cap_grn",
	"H_Cap_oli",
	"H_Cap_surfer",
	"H_Cap_tan",
	"H_Cap_khaki_specops_UK",
	"H_Cap_usblack",
	"DAR_Stetson",
	"H_HelmetCrew_I",
	"FIR_GroundCrew_Headset",
	"FIR_GroundCrew_Headset2",
	"H_PilotHelmetHeli_O",
	"H_PilotHelmetHeli_B",
	"FIR_USHelmetType1_Black_Close",
	"FIR_USHelmetType1_Navy_Black_Close",
	"FIR_USHelmetType1_USMC_Black_Close",
	"FIR_USHelmetType1_Black_Open",
	"FIR_USHelmetType1_Navy_Black_Open",
	"FIR_USHelmetType1_USMC_Black_Open",
	"FIR_USHelmetType1_Clear_Close",
	"FIR_USHelmetType1_Navy_Clear_Close",
	"FIR_USHelmetType1_USMC_Clear_Close",
	"FIR_USHelmetType1_Clear_Open",
	"FIR_USHelmetType1_Navy_Clear_Open",
	"FIR_USHelmetType1_USMC_Clear_Open",
	"FIR_USHelmetType1_Navy_Night",
	"FIR_USHelmetType1_Night",
	"FIR_USHelmetType1_USMC_Night",
	"H_CrewHelmetHeli_O",
	"H_CrewHelmetHeli_B",
	"H_Cap_marshal",
	"H_Cap_headphones"
];

_availableGoggles = [
	"G_Aviator",
	"rhs_balaclava",
	"G_Balaclava_blk",
	"G_Balaclava_oli",
	"G_Bandanna_aviator",
	"G_Bandanna_blk",
	"G_Bandanna_khk",
	"G_Bandanna_oli",
	"G_Bandanna_tan",
	"rhs_scarf",
	"G_Spectacles",
	"G_Squares_Tinted",
	"G_Squares",
	"G_Spectacles_Tinted"
];

_availableUniforms = [
	"UNS_ARMY_BDU",
	"UNS_ARMY_BDU_65",
	"UNS_ARMY_BDU_F",
	"UNS_DUCK_BDU",
	"UNS_Pilot_BDU",
	"UNS_JPilot_BDU",
	"UNS_PBR_Flak",
	"UNS_PBR_Flak_S",
	"UNS_NZ_ARMY_BDU",
	"UNS_USMC_BDU",
	"UNS_USMC_BDU_65_2",
	"UNS_USMC_BDU_65",
	"UNS_USMC_BDU_S",
	"UNS_USMC_Flak_E",
	"UNS_USMC_Flak_ES",
	"UNS_USMC_Flak",
	"UNS_USMC_Flak_F",
	"UNS_USMC_Flak_S",
	"UNS_USMC_FLAK_65",
	"UNS_USMC_FLAK2_65",
	"UNS_USMC_LERDL",
	"FIR_Fighter_Pilot_Nomex3",
	"FIR_Fighter_Pilot_Nomex4",
	"FIR_Fighter_Pilot_JASDF_Nomex3",
	"FIR_Fighter_Pilot_JASDF_Nomex4",
	"usm_bdu_blk",
	"usm_bdu_odg",
	"usm_bdu_w",
	"usm_bdu_w_m",
	"U_BG_Guerrilla_6_1",
	"U_BG_Guerilla1_1",
	"U_BG_Guerilla2_2",
	"U_BG_Guerilla2_1",
	"U_BG_Guerilla2_3",
	"U_BG_Guerilla3_1",
	"U_BG_leader",
	"U_B_HeliPilotCoveralls",
	"U_C_HunterBody_grn",
	"rhsgref_uniform_alpenflage",
	"rhsgref_uniform_flecktarn",
	"rhsgref_uniform_tigerstripe",
	"rhsgref_uniform_reed",
	"rhsgref_uniform_woodland",
	"rhsgref_uniform_woodland_olive",
	"U_O_PilotCoveralls",
	"U_B_PilotCoveralls",
	"U_C_WorkerCoveralls"
];

_availableVests = [
	"UNS_M1956_A1",
	"UNS_M1956_A10",
	"UNS_M1956_A11",
	"UNS_M1956_A12",
	"UNS_M1956_A2",
	"UNS_M1956_A3",
	"UNS_M1956_A4",
	"UNS_M1956_A5",
	"UNS_M1956_A6",
	"UNS_M1956_A7",
	"UNS_M1956_A8",
	"UNS_M1956_A9",
	"UNS_JP_Vest",
	"UNS_FLAK",
	"UNS_M1956_S1",
	"UNS_M1956_S2",
	"UNS_M1956_S3",
	"UNS_M1956_S4",
	"UNS_M1956_T1",
	"UNS_M1956_P1",
	"UNS_M1956_M1",
	"UNS_M1956_M10",
	"UNS_M1956_M11",
	"UNS_M1956_M12",
	"UNS_M1956_M13",
	"UNS_M1956_M14",
	"UNS_M1956_M15",
	"UNS_M1956_M16",
	"UNS_M1956_M17",
	"UNS_M1956_M18",
	"UNS_M1956_M19",
	"UNS_M1956_M2",
	"UNS_M1956_M3",
	"UNS_M1956_M4",
	"UNS_M1956_M5",
	"UNS_M1956_M6",
	"UNS_M1956_M7",
	"UNS_M1956_M8",
	"UNS_M1956_M9",
	"usm_vest_LBE_rm",
	"usm_vest_LBE_rm_m",
	"usm_vest_LBE_rmp",
	"usm_vest_LBE_rmp_m",
	"usm_vest_LBE_gr",
	"usm_vest_LBE_gr_m",
	"usm_vest_lbv_gr",
	"usm_vest_lbv_gr_m",
	"usm_vest_lbv_mg",
	"usm_vest_lbv_mg_m",
	"usm_vest_LBE_mg",
	"usm_vest_LBE_mg_m",
	"usm_vest_lbv_rmp",
	"usm_vest_lbv_rmp_m",
	"usm_vest_lbv_rm",
	"usm_vest_lbv_rm_m",
	"FIR_SaftyVest_Orange",
	"FIR_SaftyVest_Yellow",
	"rhs_vest_commander",
	"FIR_pilot_vest",
	"rhs_vest_pistol_holster",
	"V_Rangemaster_belt",
	"V_BandollierB_blk",
	"V_BandollierB_cbr",
	"V_BandollierB_rgr",
	"V_BandollierB_khk",
	"V_BandollierB_oli",
	"V_TacVest_blk",
	"V_TacVest_brn",
	"V_TacVest_camo",
	"V_TacVest_khk",
	"V_TacVest_oli",
	"V_Press_F",
	"usm_vest_pasgt",
	"usm_vest_pasgt_lbe_gr",
	"usm_vest_pasgt_lbe_gr_m",
	"usm_vest_pasgt_lbe_mg",
	"usm_vest_pasgt_lbe_mg_m",
	"usm_vest_pasgt_lbe_rmp",
	"usm_vest_pasgt_lbe_rmp_m",
	"usm_vest_pasgt_lbe_rm",
	"usm_vest_pasgt_lbe_rm_m",
	"usm_vest_pasgt_lbv_gr",
	"usm_vest_pasgt_lbv_gr_m",
	"usm_vest_pasgt_lbv_mg",
	"usm_vest_pasgt_lbv_mg_m",
	"usm_vest_pasgt_lbv_rmp",
	"usm_vest_pasgt_lbv_rmp_m",
	"usm_vest_pasgt_lbv_rm",
	"usm_vest_pasgt_lbv_rm_m",
	"usm_vest_rba",
	"usm_vest_rba_lbe_gr",
	"usm_vest_rba_lbe_mg",
	"usm_vest_rba_lbe_rmp",
	"usm_vest_rba_lbe_rm",
	"usm_vest_rba_lbv_gr",
	"usm_vest_rba_lbv_mg",
	"usm_vest_rba_lbv_rmp",
	"usm_vest_rba_lbv_rm",
	"usm_vest_safety"
];

_availableBackpacks = [
	"UNS_Alice_1",
	"UNS_Alice_2",
	"UNS_Alice_3",
	"UNS_Alice_4",
	"UNS_Alice_5",
	"UNS_Alice_6",
	"UNS_Alice_F3",
	"UNS_Alice_F4",
	"UNS_Alice_F5",
	"UNS_Alice_F6",
	"UNS_Alice_F7",
	"UNS_Alice_F8",
	"UNS_Alice_F9",
	"UNS_ARMY_MED",
	"UNS_ARMY_RTO",
	"UNS_SF_RTO",
	"UNS_BA22_Para",
	"UNS_NVA_MED",
	"UNS_NVA_RPG",
	"UNS_NVA_RTO",
	"UNS_NVA_R1",
	"UNS_NVA_RC",
	"UNS_TROP_R1",
	"UNS_TROP_R2",
	"UNS_TROP_R3",
	"UNS_Alice_F1",
	"UNS_Alice_F2",
	"UNS_Alice_FR",
	"UNS_USMC_MED",
	"UNS_USMC_E2",
	"UNS_USMC_E1",
	"UNS_USMC_E3",
	"UNS_USMC_RTO",
	"UNS_USMC_R3",
	"UNS_USMC_R1",
	"UNS_USMC_R2",
	"usm_pack_m5_medic",
	"usm_pack_200rnd_556_bandoliers",
	"usm_pack_762x51_bandoliers",
	"B_Respawn_Sleeping_bag_blue_F",
	"B_Respawn_Sleeping_bag_brown_F",
	"B_Respawn_TentDome_F",
	"B_Respawn_Sleeping_bag_F",
	"B_Respawn_TentA_F",
	"B_Carryall_cbr",
	"B_Carryall_khk",
	"B_Carryall_oli",
	"usm_pack_alice",
	"usm_pack_alice_medic",
	"RHS_M2_Gun_Bag",
	"RHS_M2_Tripod_Bag",
	"rhs_rpg_empty",
	"tf_rt1523g_black",
	"tf_rt1523g_fabric",
	"tf_rt1523g_green",
	"tf_rt1523g_rhs",
	"tf_rt1523g_sage",
	"rhs_sidor",
	"B_Parachute",
	"uns_Tripod_Bag",
	"rhs_assault_umbts",
	"rhs_assault_umbts_engineer_empty",
	"uns_ammopack",
	"uns_MK18_low_US_Bag",
	"uns_M1_81mm_mortar_US_Bag",
	"uns_M1919_low_US_Bag",
	"uns_M2_60mm_mortar_US_Bag",
	"uns_m2_high_US_Bag",
	"uns_M2_low_US_Bag",
	"uns_M30_107mm_mortar_US_Bag",
	"uns_M60_low_US_Bag"
];

_availableWeapons = [
	"uns_m1garand",
	"uns_m14"
];

_availableMagzines = [
	""
];


//Populate with predefined items and whatever is already in the crate
[_crate,((backpackCargo _crate) + _availableBackpacks)] call BIS_fnc_addVirtualBackpackCargo;
[_crate,((itemCargo _crate) + _availableHeadgear + _availableGoggles + _availableUniforms + _availableVests)] call BIS_fnc_addVirtualItemCargo;
[_crate,(magazineCargo _crate)] call BIS_fnc_addVirtualMagazineCargo;
[_crate,(weaponCargo _crate)] call BIS_fnc_addVirtualWeaponCargo;

Share this post


Link to post
Share on other sites

As suspected, you declare but never use that array.  If you want to add those weapons to whatever the crate already had (as you are doing with the other items) change your last line of the script to this:

[_crate,(weaponCargo _crate) + _availableWeapons] call BIS_fnc_addVirtualWeaponCargo;

Same with the magazines line if you want to include extra magazines.

Share this post


Link to post
Share on other sites

Ah, excellent.

 

And if I want to just add all magazines, which will only show up for whichever guns are present in the arsenal, do I use

_availableMagazines = [
	""
];

Or is there another method of allowing all?

Share this post


Link to post
Share on other sites

Oh goodness, no, if you wanted to do that automatically you're gonna have a bunch of config and muzzle lookups.  You could possibly adjust this code for that.

 

This seems to work using serena's code:

//Init stuff
params ["_crate"];
["AmmoboxInit",[_crate,false,{true}]] spawn BIS_fnc_arsenal;

//Lists of items to include
_availableWeapons = [
	"arifle_ARX_ghex_DMS_Pointer_Snds_Bipod_F",
	"srifle_DMR_07_blk_DMS_Snds_F",
	"arifle_AK12_F"
];

_availableMagzines = [];

_allowedWeapons = (weaponCargo _crate) + _availableWeapons;

Fn_Gear_CompatibleMagazines = {
	private _cls = configFile >> "CfgWeapons" >> _this;
	private _res = [];
	{_res pushBack (if (_x == "this")
		then {getArray(_cls >> "magazines")}
		else {getArray(_cls >> _x >> "magazines")});
	} forEach getArray(_cls >> "muzzles");

	_res
};

{	if (count _x > 0) then {
		{	if (count _x > 0) then {			
				_availableMagzines pushBack (_x select 0)}
		} foreach (_x call Fn_Gear_CompatibleMagazines)	
	}
} forEach _allowedWeapons;

_allowedMagazines = (magazineCargo _crate) + _availableMagzines;

//Populate with predefined items and whatever is already in the crate
[_crate, _allowedWeapons] call BIS_fnc_addVirtualWeaponCargo;
[_crate, _allowedMagazines] call BIS_fnc_addVirtualMagazineCargo;
  • Like 1

Share this post


Link to post
Share on other sites

---edited out post, issue resolved----

Share this post


Link to post
Share on other sites

kylania, this is working well, but it's not showing all of the compatible magazines, just one or two. Is there any way to get every mag that will fit the weapon to show?

 

Thank you,

Share this post


Link to post
Share on other sites

I think This will do it, tested as working:

{	
	if (count _x > 0) then 
	{
		{	
			if (count _x > 0) then 
			{			
				{
					_availableMagzines pushBack _x; // x-ception!
				} forEach _x;
				
			}
		} forEach (_x call Fn_Gear_CompatibleMagazines);	
	}
} forEach _allowedWeapons;

Basically it was pulling the array of magazines for each weapon but only adding the first.  Untested as I'm away from the game at the moment though. :)

Share this post


Link to post
Share on other sites

Thanks Kylania,

 

Only issue I am having now is that when you click the "load" button, it takes a bit to bring up the arsenal, usually kicking people from the task force radio channel on our teamspeak server and then bringing them back in due to the game freezing.

 

Any idea why this is? I'm guessing it's because they have to load the script each time they access the arsenal, is there a better solution?

 

Thank you.

Share this post


Link to post
Share on other sites

Any idea why this is? I'm guessing it's because they have to load the script each time they access the arsenal, is there a better solution?

Has this delay been there before you added the magazine function? If not, and it's really due to the magazine thing, you could just run the magazine thing once during mission init (on each client) and make it available as a global variable.

Share this post


Link to post
Share on other sites

Load button?  That script is intended to be run once at game start, not every time you access the box.  

 

If you're using a bunch of weapon mods then of course you'll have a ton of processing time.  Instead of leaving it to dynamically include every possible type of magazine, just hand whitelist the few people will actually use, just like you are with everything else.  Whitelisting, but then including everything via config lookups, isn't really whitelisting, is it?

Share this post


Link to post
Share on other sites

It happened before the magazine script, it also happens when i make a "filtered arsenal" using the ACE/Ares presets in 3d editor and zeus.

 

When the players go to load a kit, it freezes the game for about 20-30 seconds.

I also tried removing the magazine script and doing it manually, it still freezes the game, so it's not the custom lookup, it's the act of whitelisting that is causing the freeze. 

 

I have been on other servers before though with white listed arsenals and not ran into this. Any idea what the issue could be?

 

Thanks!

Share this post


Link to post
Share on other sites

Probably because you have so many weapons?  When the mission my friend was playing had RHS, vanilla, HLC, SMA and like 2-3 other weapon mods it definitely took forever to load the first time.  Finally got rid of all the other mods other than RHS* and things are reasonable now.

 

* Sorry, I've been asked to clarify this statement "Finally got rid of all the other mods other than RHS".

 

I meant to say "After someone suggested we replace VSM with some new gear mods our admin went totally insane and while ignoring my childish whining and endless complaining still removed almost 15GB of gear mods that, while we rarely used most of them, many of our players favorite weapons were in them.  However now our Arsenal loads in a reasonable time.  I WILL HAVE MY CUP BACK YOU BASTARD!"

  • Like 2

Share this post


Link to post
Share on other sites

Probably because you have so many weapons?  When the mission my friend was playing had RHS, vanilla, HLC, SMA and like 2-3 other weapon mods it definitely took forever to load the first time.  Finally got rid of all the other mods other than RHS* and things are reasonable now.

 

* Sorry, I've been asked to clarify this statement "Finally got rid of all the other mods other than RHS".

 

I meant to say "After someone suggested we replace VSM with some new gear mods our admin went totally insane and while ignoring my childish whining and endless complaining still removed almost 15GB of gear mods that, while we rarely used most of them, many of our players favorite weapons were in them.  However now our Arsenal loads in a reasonable time.  I WILL HAVE MY CUP BACK YOU BASTARD!"

Better.

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

×