Jump to content
Sign in to follow this  
proffrink

Loadout Script Repeating For Every Unit

Recommended Posts

Hey all. Thanks for the helpful advice over the past few weeks. These forums have really helped me get into a bit of (very light) ArmA scripting and it's helped make various missions more interesting.

I'm using a loadout script (actually found on ArmAHolic), but it's 'duplicating' ammunition and giving people/units all the weapons from every individual .sqf file.

I know the problem is in defining the unit itself in the very first line (as every 'player' is called _Unit), but I'm not sure how to distinguish them. Here's an example of AT_Specialist_SMAW_OD_loadout.sqf:

	[b]_MyUnit = player;[/b] 
// Main Slot clearance	
removeAllWeapons _MyUnit;
removeAllItems _MyUnit;	
removeBackpack _MyUnit;

// Equipment stocking
_MyUnit addWeapon "ItemCompass";	
_MyUnit addWeapon "ItemWatch";
_MyUnit addWeapon "ACE_Earplugs";
_MyUnit addWeapon "ACE_GlassesBalaklavaOlive";
_MyUnit addWeapon "ACE_GlassesLHD_glasses";

// Medical stocking
{_MyUnit addMagazine "ACE_Bandage"} forEach [1,2,3];

// Radio stocking
_MyUnit addWeapon "ACRE_PRC148_UHF";

// Primary and Secondary stocking
{_MyUnit addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5,6,7];
_MyUnit addWeapon "ACE_HK416_D10_COMPM3";

// AT
_MyUnit addWeapon "SMAW";
_MyUnit addMagazine "SMAW_HEAA";
_MyUnit addMagazine "ACE_SMAW_Spotting";

// Side & M203 Ammo slot stocking	


// Backpack Selection & Slot clearance
_MyUnit addWeapon "ACE_VTAC_RUSH72_OD";
_MyBackpack = unitBackpack _MyUnit;
clearWeaponCargo (unitBackpack _MyUnit);
clearMagazineCargo (unitBackpack _MyUnit);
//WARNING if using VTAC Medic, then be advised that the above two lines remove all backpack contents!

// Backpack slot stocking
// Remember; different syntax
[_MyUnit, "SMAW_HEAA",1] call ACE_fnc_PackMagazine;
[_MyUnit, "ACE_SMAW_Spotting",1] call ACE_fnc_PackMagazine;
[_MyUnit, "SmokeShell",1] call ACE_fnc_PackMagazine;

[_MyUnit, "ACE_Morphine",1] call ACE_fnc_PackMagazine;

Here are another 2 loadouts that are similar:

Designated_Marksman_OD_loadout.sqf

  _MyUnit = player; 
// Main Slot clearance	
removeAllWeapons _MyUnit;
removeAllItems _MyUnit;	
removeBackpack _MyUnit;

// Equipment stocking
_MyUnit addWeapon "ItemCompass";	
_MyUnit addWeapon "ItemWatch";
_MyUnit addWeapon "ACE_Earplugs";
_MyUnit addWeapon "ACE_GlassesBalaklavaOlive";

// Medical stocking
{_MyUnit addMagazine "ACE_Bandage"} forEach [1,2,3];

// Radio stocking
_MyUnit addWeapon "ACRE_PRC148_UHF";

// Primary and Secondary stocking
{_MyUnit addMagazine "100Rnd_556x45_M249"} forEach [1,2,3,4,5];
_MyUnit addWeapon "ACE_M249_AIM";
_MyUnit addWeapon "ACE_SpareBarrel";

// AT


// Side & M203 Ammo slot stocking	


// Backpack Selection & Slot clearance
_MyUnit addWeapon "ACE_VTAC_RUSH72_OD";
_MyBackpack = unitBackpack _MyUnit;
clearWeaponCargo (unitBackpack _MyUnit);
clearMagazineCargo (unitBackpack _MyUnit);
//WARNING if using VTAC Medic, then be advised that the above two lines remove all backpack contents!

// Backpack slot stocking
// Remember; different syntax
[_MyUnit, "100Rnd_556x45_M249",2] call ACE_fnc_PackMagazine;
[_MyUnit, "ACE_100Rnd_556x45_T_M249",3] call ACE_fnc_PackMagazine;
[_MyUnit, "HandGrenade_West",2] call ACE_fnc_PackMagazine;
[_MyUnit, "SmokeShell",2] call ACE_fnc_PackMagazine;

[_MyUnit, "ACE_Morphine",1] call ACE_fnc_PackMagazine;

Automatic_Rifleman_OD_loadout.sqf

	_MyUnit = player; 
// Main Slot clearance	
removeAllWeapons _MyUnit;
removeAllItems _MyUnit;	
removeBackpack _MyUnit;

// Equipment stocking
_MyUnit addWeapon "ItemCompass";	
_MyUnit addWeapon "ItemWatch";
_MyUnit addWeapon "ACE_Earplugs";
_MyUnit addWeapon "ACE_GlassesBalaklavaOlive";
_MyUnit addWeapon "Binocular";

// Medical stocking
{_MyUnit addMagazine "ACE_Bandage"} forEach [1,2,3];

// Radio stocking
_MyUnit addWeapon "ACRE_PRC148_UHF";

// Primary and Secondary stocking
_MyUnit addWeapon "ACE_KAC_PDW";
this setVariable ["ACE_weapononback", "ACE_KAC_PDW"];
{_MyUnit addMagazine "ACE_20Rnd_762x51_T_HK417"} forEach [1];
{_MyUnit addMagazine "ACE_20Rnd_762x51_S_HK417"} forEach [1,2,3,4,5];
{_MyUnit addMagazine "ACE_20Rnd_762x51_T_HK417"} forEach [1];
{_MyUnit addMagazine "ACE_30Rnd_6x35_B_PDW"} forEach [1,2,3,4];
{_MyUnit addMagazine "SmokeShell"} forEach [1];
_MyUnit addWeapon "ACE_HK417_Shortdot";

// AT


// Side & M203 Ammo slot stocking
this setVariable ["ACE_weapononback", "ACE_KAC_PDW"];


// Backpack Selection & Slot clearance
_MyUnit addWeapon "ACE_VTAC_RUSH72_OD";
_MyBackpack = unitBackpack _MyUnit;
clearWeaponCargo (unitBackpack _MyUnit);
clearMagazineCargo (unitBackpack _MyUnit);
//WARNING if using VTAC Medic, then be advised that the above two lines remove all backpack contents!

// Backpack slot stocking
// Remember; different syntax
[_MyUnit, "ACE_20Rnd_762x51_T_HK417",1] call ACE_fnc_PackMagazine;
[_MyUnit, "ACE_20Rnd_762x51_S_HK417",2] call ACE_fnc_PackMagazine;
[_MyUnit, "ACE_30Rnd_6x35_B_PDW",4] call ACE_fnc_PackMagazine;
[_MyUnit, "SmokeShell",1] call ACE_fnc_PackMagazine;

[_MyUnit, "ACE_Morphine",1] call ACE_fnc_PackMagazine;

I've searched a bit, but I'm finding it difficult to be specific. I've spent a while setting up 10 of these loadouts, and I'd really like to be able to fix this current one rather than start from scratch.

Thank you in advance for any help!

Share this post


Link to post
Share on other sites

This is what i did and it works great :)

waitUntil {!isNil "bis_fnc_init"};
_unit = _this select 0;

if(local _unit) then {



// Remove original equipment
removeallweapons _unit;
removeallassigneditems _unit;
removeallcontainers _unit;


// Add clothing
_unit addUniform "U_B_CombatUniform_mcam";
_unit addHeadgear "H_HelmetB";
_unit addVest "V_PlateCarrier1_cbr";
_unit addBackpack "B_AssaultPack_blk";


// Add weapons & grenades
_unit addMagazines ["3Rnd_HE_Grenade_shell", 2];
_unit addMagazines ["3Rnd_SmokeRed_Grenade_shell", 2];
_unit addMagazines ["3Rnd_Smoke_Grenade_shell", 2];
_unit addMagazines ["3Rnd_SmokeYellow_Grenade_shell", 2];
_unit addMagazines ["3Rnd_SmokeGreen_Grenade_shell", 2];
_unit addMagazines ["3Rnd_SmokePurple_Grenade_shell", 2];
_unit addMagazines ["3Rnd_SmokeOrange_Grenade_shell", 2];
_unit addMagazines ["3Rnd_SmokeBlue_Grenade_shell", 2];
_unit addMagazines ["3Rnd_UGL_FlareCIR_F", 2];

_unit addMagazines ["30Rnd_65x39_caseless_mag", 14];
_unit addWeapon "arifle_MX_GL_F";
_unit addPrimaryWeaponitem "optic_Hamr";
_unit addPrimaryWeaponItem "acc_pointer_IR";

_unit addMagazines ["30Rnd_9x21_Mag", 2];
_unit addWeapon "hgun_P07_F";

_unit addMagazines ["HandGrenade", 3];
_unit addMagazines ["SmokeShellRed", 2];
_unit addMagazines ["SmokeShell", 2];
_unit addMagazines ["SmokeShellGreen", 2];
_unit addMagazines ["SmokeShellBlue", 2];

_unit addMagazines ["Chemlight_green", 4];
_unit addMagazines ["Chemlight_blue", 4];


// Add items
_unit addMagazines ["FirstAidKit", 3];

_unit addWeapon "Binocular";

_unit addItem "muzzle_snds_H"; 
_unit addItem "muzzle_snds_L"; 

_unit addItem "NVGoggles"; 
_unit assignItem "NVGoggles"; 

_unit addItem "ItemRadio"; 
_unit assignItem "ItemRadio";

_unit addItem "g_tactical_clear"; 
_unit assignItem "g_tactical_clear"; 

_unit addItem "ItemCompass"; 
_unit assignItem "ItemCompass"; 

_unit addItem "ItemMap"; 
_unit assignItem "ItemMap"; 

_unit addItem "ItemWatch"; 
_unit assignItem "ItemWatch"; 

_unit addItem "ItemGPS"; 
_unit assignItem "ItemGPS";
};

Even though this is for arma 3, i dont believe it has changed a whole lot from arma 2.

Edited by Byrgesen

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
Sign in to follow this  

×