aDIRTYnurse 6 Posted January 20, 2020 Hey I need another pair of eyes to take a look a this. What am I missing? The script itself works, but when the mk17 gets picked, the "else" section still goes into action. If the M14ebr, DMR_camo or sr25 get selected, the mag are okay, but with the mk17, it still adds the unusable ACE mags. Script: Spoiler comment "Remove existing items"; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; comment "Add weapons"; _rifle = ["rhs_weap_m14ebrri", 0.75, "rhs_weap_mk17_STD", 0.50, "srifle_DMR_06_camo_F", 0.20, "rhs_weap_sr25_d", 0.50] call BIS_fnc_selectRandomWeighted; player addWeapon _rifle; player addPrimaryWeaponItem "optic_MRCO"; if (_rifle isEqualTo "rhs_weap_mk17_STD") then { player addPrimaryWeaponItem "rhsusf_acc_anpeq15_wmx_sc"; player addPrimaryWeaponItem "rhsgref_sdn6_suppressor"; } else { player addPrimaryWeaponItem "rhsusf_acc_anpeq15side"; }; player addPrimaryWeaponItem "rhsusf_acc_sr25s_d"; player addPrimaryWeaponItem "rhsusf_acc_harris_bipod"; comment "Add containers"; player forceAddUniform "milgp_u_g3_field_set_mc"; player addItemToUniform "ACE_epinephrine"; for "_i" from 1 to 5 do {player addItemToUniform "ACE_elasticBandage";}; for "_i" from 1 to 3 do {player addItemToUniform "ACE_tourniquet";}; player addItemToUniform "ACE_CableTie"; player addItemToUniform "ACE_EarPlugs"; player addItemToUniform "ACE_Flashlight_MX991"; player addItemToUniform "ACE_MapTools"; player addItemToUniform "B_IR_Grenade"; player addItemToUniform "Chemlight_green"; player addItemToUniform "ACE_Chemlight_IR"; player addItemToUniform "Chemlight_red"; for "_i" from 1 to 3 do {player addItemToUniform "rhsusf_mag_15Rnd_9x19_JHP";}; _array = ["rhsusf_spcs_ocp_sniper", "milgp_v_marciras_marksman_mc", "milgp_v_marciras_marksman_belt_mc"]; _vest = selectRandom _array; player addVest _vest; player addItemToVest "ACE_microDAGR"; for "_i" from 1 to 2 do {player addItemToVest "HandGrenade";}; player addItemToVest "ACE_EntrenchingTool"; for "_i" from 1 to 2 do {player addItemToVest "SmokeShell";}; player addItemToVest "SmokeShellBlue"; player addBackpack "TRYK_B_BAF_BAG_mcamo";_array = ["rhs_mag_20Rnd_SCAR_762x51_mk316_special", "rhs_mag_20Rnd_SCAR_762x51_mk316_special_bk"]; _mag1 = selectRandom _array; _array = ["rhs_mag_20Rnd_SCAR_762x51_m61_ap", "rhs_mag_20Rnd_SCAR_762x51_m61_ap_bk"]; _mag2 = selectRandom _array; if (_rifle isEqualTo "rhs_weap_mk17_STD") then { for "_i" from 1 to 4 do {player addItemToBackpack _mag1;}; for "_i" from 1 to 3 do {player addItemToBackpack _mag2;}; } or if (_rifle isEqualTo "rhs_weap_sr25_d") then { for "_i" from 1 to 4 do {player addItemToBackpack "rhsusf_20Rnd_762x51_SR25_m118_special_Mag";}; for "_i" from 1 to 3 do {player addItemToBackpack "rhsusf_20Rnd_762x51_SR25_m993_Mag";}; } else { for "_i" from 1 to 4 do {player addItemToBackpack "ACE_20Rnd_762x51_M118LR_Mag";}; for "_i" from 1 to 3 do {player addItemToBackpack "ACE_20Rnd_762x51_M993_AP_Mag";}; }; _array = ["rhsusf_ach_helmet_ocp_norotos", "rhsusf_ach_helmet_camo_ocp", "rhsusf_ach_helmet_headset_ess_ocp", "rhsusf_ach_helmet_headset_ocp", "rhsusf_ach_helmet_ESS_ocp", "rhsusf_ach_helmet_ocp"]; _helmet = selectRandom _array; player addHeadgear _helmet; player addWeapon "rhsusf_weap_m9"; comment "Add items"; player linkItem "ItemMap"; player linkItem "ItemCompass"; player linkItem "tf_microdagr"; player linkItem "tf_anprc152"; player linkItem "ItemGPS"; player linkItem "rhsusf_ANPVS_14"; player setSpeaker "ACE_NoVoice"; player setVariable ["ACE_GForceCoef", 1]; [[player],"ace_medical_medicClass", 1, true] call ace_common_fnc_assignObjectsInList; [[player],"ACE_IsEngineer", 1, true] call ace_common_fnc_assignObjectsInList; Share this post Link to post Share on other sites
Maff 250 Posted January 20, 2020 Take another look at Line 53. } or // Should be }; Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 If I put a semicolon at the end, it breaks/stops the script entirely Share this post Link to post Share on other sites
Maff 250 Posted January 20, 2020 4 minutes ago, aDIRTYnurse said: If I put a semicolon at the end, it breaks/stops the script entirely So the player never gets the M9? I'm firing up ArmA... Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 They do. The M9 is at the end, so it would have the magazine loaded. Share this post Link to post Share on other sites
Maff 250 Posted January 20, 2020 I tested it in ArmA and it works for me when adding the semicolon on line 53. I had to change some of the class names as I don't have the mods. Are you running all the required mods? Spoiler comment "Remove existing items"; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; comment "Add weapons"; _rifle = ["rhs_weap_m14ebrri", 0.75, "rhs_weap_mk17_STD", 0.50, "srifle_DMR_06_camo_F", 0.20, "rhs_weap_sr25_d", 0.50] call BIS_fnc_selectRandomWeighted; player addWeapon _rifle; player addPrimaryWeaponItem "optic_MRCO"; if (_rifle isEqualTo "rhs_weap_mk17_STD") then { player addPrimaryWeaponItem "rhsusf_acc_anpeq15_wmx_sc"; player addPrimaryWeaponItem "rhsgref_sdn6_suppressor"; } else { player addPrimaryWeaponItem "rhsusf_acc_anpeq15side"; }; player addPrimaryWeaponItem "rhsusf_acc_sr25s_d"; player addPrimaryWeaponItem "rhsusf_acc_harris_bipod"; comment "Add containers"; player forceAddUniform "U_B_CombatUniform_mcam"; player addItemToUniform "ACE_epinephrine"; for "_i" from 1 to 5 do {player addItemToUniform "ACE_elasticBandage";}; for "_i" from 1 to 3 do {player addItemToUniform "ACE_tourniquet";}; player addItemToUniform "ACE_CableTie"; player addItemToUniform "ACE_EarPlugs"; player addItemToUniform "ACE_Flashlight_MX991"; player addItemToUniform "ACE_MapTools"; player addItemToUniform "B_IR_Grenade"; player addItemToUniform "Chemlight_green"; player addItemToUniform "ACE_Chemlight_IR"; player addItemToUniform "Chemlight_red"; for "_i" from 1 to 3 do {player addItemToUniform "rhsusf_mag_15Rnd_9x19_JHP";}; _array = ["rhsusf_spcs_ocp_sniper", "rhsusf_spcs_ocp_sniper", "rhsusf_spcs_ocp_sniper"]; _vest = selectRandom _array; player addVest _vest; player addItemToVest "ACE_microDAGR"; for "_i" from 1 to 2 do {player addItemToVest "HandGrenade";}; player addItemToVest "ACE_EntrenchingTool"; for "_i" from 1 to 2 do {player addItemToVest "SmokeShell";}; player addItemToVest "SmokeShellBlue"; player addBackpack "B_Carryall_mcamo"; _array = ["rhs_mag_20Rnd_SCAR_762x51_mk316_special", "rhs_mag_20Rnd_SCAR_762x51_mk316_special_bk"]; _mag1 = selectRandom _array; _array = ["rhs_mag_20Rnd_SCAR_762x51_m61_ap", "rhs_mag_20Rnd_SCAR_762x51_m61_ap_bk"]; _mag2 = selectRandom _array; if (_rifle isEqualTo "rhs_weap_mk17_STD") then { for "_i" from 1 to 4 do {player addItemToBackpack _mag1;}; for "_i" from 1 to 3 do {player addItemToBackpack _mag2;}; }; // Edited! if (_rifle isEqualTo "rhs_weap_sr25_d") then { for "_i" from 1 to 4 do {player addItemToBackpack "rhsusf_20Rnd_762x51_SR25_m118_special_Mag";}; for "_i" from 1 to 3 do {player addItemToBackpack "rhsusf_20Rnd_762x51_SR25_m993_Mag";}; } else { for "_i" from 1 to 4 do {player addItemToBackpack "ACE_20Rnd_762x51_M118LR_Mag";}; for "_i" from 1 to 3 do {player addItemToBackpack "ACE_20Rnd_762x51_M993_AP_Mag";}; }; _array = ["rhsusf_ach_helmet_ocp_norotos", "rhsusf_ach_helmet_camo_ocp", "rhsusf_ach_helmet_headset_ess_ocp", "rhsusf_ach_helmet_headset_ocp", "rhsusf_ach_helmet_ESS_ocp", "rhsusf_ach_helmet_ocp"]; _helmet = selectRandom _array; player addHeadgear _helmet; player addWeapon "rhsusf_weap_m9"; comment "Add items"; player linkItem "ItemMap"; player linkItem "ItemCompass"; player linkItem "tf_microdagr"; player linkItem "tf_anprc152"; player linkItem "ItemGPS"; player linkItem "rhsusf_ANPVS_14"; player setSpeaker "ACE_NoVoice"; player setVariable ["ACE_GForceCoef", 1]; [[player],"ace_medical_medicClass", 1, true] call ace_common_fnc_assignObjectsInList; [[player],"ACE_IsEngineer", 1, true] call ace_common_fnc_assignObjectsInList; Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 Sorry I'm stupid. Your M9 question. No. If I put the semicolon at the end, then the player does not get the M9. Nothing happens. I use ACE Arsenal to test these loadout scripts. Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 So you took the "or" function away entirely? Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 Without the "or" function the outcome is still the same as in the beginning. When the Mk17 is picked, the ACE mags in the "else" section still get added to the backpack. Share this post Link to post Share on other sites
Maff 250 Posted January 20, 2020 OK. I just noticed you edited your first post. // MK 17 is selected then all is good. if (_rifle isEqualTo "rhs_weap_mk17_STD") then { for "_i" from 1 to 4 do {player addItemToBackpack _mag1;}; for "_i" from 1 to 3 do {player addItemToBackpack _mag2;}; }; // But below you have if () then {} else {}; // Which adds the unusable 7.62 mags to the MK17 loadout. if (_rifle isEqualTo "rhs_weap_sr25_d") then { for "_i" from 1 to 4 do {player addItemToBackpack "rhsusf_20Rnd_762x51_SR25_m118_special_Mag";}; for "_i" from 1 to 3 do {player addItemToBackpack "rhsusf_20Rnd_762x51_SR25_m993_Mag";}; } else { for "_i" from 1 to 4 do {player addItemToBackpack "ACE_20Rnd_762x51_M118LR_Mag";}; for "_i" from 1 to 3 do {player addItemToBackpack "ACE_20Rnd_762x51_M993_AP_Mag";}; }; Quick solution would be to do if (_rifle isEqualTo "THIS_WEAPON") then { }; for each of your weapons. Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 Yup. I just did that. Thanks for the quick help. I've been looking at these scripts for 2,5h now. Seeing stars at this point 😄 Have a good one 1 Share this post Link to post Share on other sites
Maff 250 Posted January 20, 2020 (edited) No bother. I have had my fair share of headaches with loadout scripts too! Have you played with setUnitLoadout yet? EDIT: You can export the loadout array from ACE Arsenal. It also looks neater in your sqf. Edited January 20, 2020 by Maff Additional info. Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 Nope. And please don't scare me with that sort of stuff 😄 1 Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 I'm guessing its for preset loadouts, that you can pick at spawn? Share this post Link to post Share on other sites
Maff 250 Posted January 20, 2020 Just now, aDIRTYnurse said: I'm guessing its for preset loadouts, that you can pick at spawn? See above. I edited my last post. You can pick a units loadout via ACE Arsenal then export it as an array and paste inside your sqf. Share this post Link to post Share on other sites
aDIRTYnurse 6 Posted January 20, 2020 To me that looks like a long array, that I can't make sense of, unless I make it presentable for myself, which is why all my code looks like the BI Arsenal script. I'm just used to it 😄 Share this post Link to post Share on other sites