Jump to content
Sign in to follow this  
LowFlyZone

Copy All Unit Gear to Clipboard

Recommended Posts

/*
This script will allow you to copy to clipboard the current gear of any unit, allowing you to paste it in the init box of another unit in the editor, or use it in another script to equip a unit.
It is mainly for customizing your gear using ammo crates or VAS and then being able to use the custom loadout easily in a mission on any unit. All gear and attachments will be in the correct slots!

Execute on any unit via init/trigger/other script, replacing [this] with [unitName] or [player] if needed:

nul = [this] execVM "copyUnitGearToClipboard.sqf";
nul = [player] execVM "copyUnitGearToClipboard.sqf";
nul = [unit1] execVM "copyUnitGearToClipboard.sqf";

When it executes a hint will be displayed showing the output and it is also copied to clipboard for you to paste somewhere else.

!!!***Thank you to NeoArmageddon for the permission to share this, basically most of the working code is his. All I did was modify it to copy to clipboard instead of copying to another unit. I also had to script alternative methods for some things because it doesn't work the same as directly copying the gear to another unit in game as the original script does***!!!

Modified from the original Script found at http://forums.bistudio.com/showthread.php?169876-Script-Copy-a-units-loadout
Author: NeoArmageddon
Website: www.modfact.net
*/
	private["_unit","_weapons","_assigned_items","_primary","_array","_blacklist","_gearText","_headGear","_vest","_uniform","_backpack","_goggles", "_handgun"];

	_unit = [_this,0,objnull,[objnull]] call bis_fnc_param;
	_gearText = "";
	//_primary = primaryWeapon _unit; //not used as variable
	//_weapons = weaponsItems _unit; //not used as variable
	//_handgun = handgunWeapon _unit; //not used as variable
	_headGear = "";
	_vest = "";
	_uniform = "";
	_backpack = "";
	_goggles = "";

	_gearText = _gearText + "removeAllWeapons this; ";
	_gearText = _gearText + "removeAllAssignedItems this; ";
	_gearText = _gearText + "removeAllContainers this; ";
	_gearText = _gearText + "removeHeadgear this; ";
	_gearText = _gearText + "removeGoggles this; ";

	if((headgear _unit)!="") then {
		_headGear = headgear _unit;
		_gearText = _gearText + format ["this addHeadgear '%1'; ", _headGear];
	};
	if((goggles _unit)!="") then {
		_goggles = goggles _unit;
		_gearText = _gearText + format ["this addGoggles '%1'; ", _goggles];
	};
	if((uniform _unit)!="") then {
		_uniform = uniform _unit;
		_gearText = _gearText + format ["this addUniform '%1'; ", _uniform];
	};
	if((vest _unit)!="") then {
		_vest = vest _unit;
		_gearText = _gearText + format ["this addVest '%1'; ", _vest];
	};
	if((backpack _unit)!="") then {
		_backpack = backpack _unit;
		_gearText = _gearText + format ["this addBackPack '%1'; ", _backpack];
	};

	//_blacklist = ["Rangefinder","Binocular"]; //binoculars and rangefinders don't get copied!
	_blacklist = [""];
	{
		if((_x select 0)!="" && !((_x select 0) in _blacklist)) then {
			//This will get the current loaded magazine in the weapon
			if(count(_x)>4) then {
				//_gearText = _gearText + format ["this addmagazine '%1'; ", [(_x select 4) select 0,(_x select 4) select 1]]; //weapon starts with no magazine!
				_gearText = _gearText + format ["this addmagazine '%1'; ", ((_x select 4) select 0)];
			};
			if(count(_x)>5) then {
				//_gearText = _gearText + format ["this addmagazine '%1'; ", [(_x select 5) select 0,(_x select 5) select 1]]; //weapon starts with no magazine!
				_gearText = _gearText + format ["this addmagazine '%1'; ", ((_x select 5) select 0)];
			};
			if((_x select 0) != "")then{_gearText = _gearText + format ["this addweapon '%1'; ", (_x select 0)];};
			//if((_x select 1) != "")then{_gearText = _gearText + format ["this linkItem '%1'; ", (_x select 1)];}; //does not add the attachment
			//if((_x select 2) != "")then{_gearText = _gearText + format ["this linkItem '%1'; ", (_x select 2)];}; //does not add the attachment
			//if((_x select 3) != "")then{_gearText = _gearText + format ["this linkItem '%1'; ", (_x select 3)];}; //does not add the attachment
		};
	} foreach (weaponsItems _unit);
	//Now the attachments get added!
	{
		if(_x != "") then{_gearText = _gearText + format ["this addPrimaryWeaponItem '%1'; ", _x];};
	} foreach (primaryWeaponItems _unit);

	{
		if(_x != "") then{_gearText = _gearText + format ["this addHandgunItem '%1'; ", _x];};
	} foreach (handgunItems _unit);

	_array = getItemCargo uniformContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToUniform '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getMagazineCargo uniformContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToUniform '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getWeaponCargo uniformContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToUniform '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getItemCargo vestContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToVest '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getMagazineCargo vestContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToVest '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getWeaponCargo vestContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToBackpack '%1'; ", _x]; ///////WEIRD?????\\\\\\\\\\
			};
		} foreach ((_array) select 0);
	};

	_array = getItemCargo backpackContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToBackpack '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getMagazineCargo backpackContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToBackpack '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	_array = getWeaponCargo backpackContainer _unit;
	if(count(_array)>0) then {
		{
			for[{_i=0},{_i<((_array) select 1) select _forEachIndex},{_i=_i+1}] do {
				_gearText = _gearText + format ["this addItemToBackpack '%1'; ", _x];
			};
		} foreach ((_array) select 0);
	};

	{
		_gearText = _gearText + format ["this linkItem '%1'; ", _x];
	} foreach assignedItems _unit;

	copyToClipboard _gearText;
	sleep 1;
	hint _gearText;

Share this post


Link to post
Share on other sites
Guest

Thanks for sending us the release :cool:

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Hi dude your script is fantastic ! , I tried it and it work great in SP

What about MP ? I know there is a bug where , when changing uniforms , you have weird issues in MP like empty vest or soldiers in underwear

do you tried to make custom setup for MP too ? if yes what scripts you use to load the setup when mission start and on respawn ?

many thanks

keep up the good work : )

Share this post


Link to post
Share on other sites

What about MP ? I know there is a bug where , when changing uniforms , you have weird issues in MP like empty vest or soldiers in underwear

do you tried to make custom setup for MP too ? if yes what scripts you use to load the setup when mission start and on respawn ?

I don't multiplay much at all (really unreliable connection sometimes) so ddn't even think about that but when I have time again soon I'll make a respawn friendly version. I know it's possible to do, probably even quite easy. It would entail having the gear pasted in an SQF file that refers to each unit that uses it for custom gear initialization that can run when the units respawn. Hopefully I can work around the MP bugs if there any using this method.

Glad you guys find it useful, for me it's the best way to customize gear instead of using overcomplex and/or none ingame methods. Wish BIS put some more thought into in game GUI customization for this stuff, it's such a critical part of making missions.

Share this post


Link to post
Share on other sites

Can someone point me how to make this script make loadout sqf a little shorter? What I mean is now after little script edit I get this:

removeAllWeapons this;

removeAllAssignedItems this;

removeAllContainers this;

removeHeadgear this;

removeGoggles this;

this addHeadgear 'ACC_H_MICH_D';

this addGoggles 'G_Aviator';

this addUniform 'ACC_U_Pantera_D';

this addVest 'ACC_V_PlateCarrier_GL_D';

this addBackPack 'ACC_Carryall_D';

this addweapon 'Binocular';

this addmagazine 'ACC_30Rnd_556x45_Beryl';

this addweapon 'ACC_Beryl_Mini_des';

this addmagazine 'ACC_16Rnd_9x19_Wist_Mag';

this addweapon 'ACC_Wist_94';

this addPrimaryWeaponItem 'FHQ_acc_ANPEQ15';

this addPrimaryWeaponItem 'FHQ_optic_HWS_tan';

(uniformContainer this) addItemCargoGlobal ['x39_bandage', 1];

(uniformContainer this) addItemCargoGlobal ['x39_bandage', 1];

(uniformContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(uniformContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(uniformContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(uniformContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(uniformContainer this) addItemCargoGlobal ['ACC_16Rnd_9x19_Wist_Mag', 1];

(uniformContainer this) addItemCargoGlobal ['ACC_16Rnd_9x19_Wist_Mag', 1];

(vestContainer this) addItemCargoGlobal ['x39_bandage', 1];

(vestContainer this) addItemCargoGlobal ['x39_bandage', 1];

(vestContainer this) addItemCargoGlobal ['x39_bandage', 1];

(vestContainer this) addItemCargoGlobal ['x39_bandage', 1];

(vestContainer this) addItemCargoGlobal ['x39_bandage', 1];

(vestContainer this) addItemCargoGlobal ['x39_morphine', 1];

(vestContainer this) addItemCargoGlobal ['x39_morphine', 1];

(vestContainer this) addItemCargoGlobal ['x39_morphine', 1];

(vestContainer this) addItemCargoGlobal ['x39_morphine', 1];

(vestContainer this) addItemCargoGlobal ['x39_morphine', 1];

(vestContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(vestContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(vestContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(vestContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(vestContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl_T', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl_T', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl_T', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl_T', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl', 1];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl', 1];

(backpackContainer this) addItemCargoGlobal ['x39_medikit5', 1];

(backpackContainer this) addItemCargoGlobal ['x39_medikit5', 1];

(backpackContainer this) addItemCargoGlobal ['x39_medikit5', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 1];

(backpackContainer this) addItemCargoGlobal ['x39_defibrillator', 1];

(backpackContainer this) addItemCargoGlobal ['x39_tourniquet', 1];

(backpackContainer this) addItemCargoGlobal ['x39_tourniquet', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 1];

this linkItem 'ItemMap';

this linkItem 'ItemCompass';

this linkItem 'ItemWatch';

this linkItem 'tf_anprc152_3';

this linkItem 'Binocular';

But I would like to make it look like this:

removeAllWeapons this;

removeAllAssignedItems this;

removeAllContainers this;

removeHeadgear this;

removeGoggles this;

this addHeadgear 'ACC_H_MICH_D';

this addGoggles 'G_Aviator';

this addUniform 'ACC_U_Pantera_D';

this addVest 'ACC_V_PlateCarrier_GL_D';

this addBackPack 'ACC_Carryall_D';

this addweapon 'Binocular';

this addmagazine 'ACC_30Rnd_556x45_Beryl';

this addweapon 'ACC_Beryl_Mini_des';

this addmagazine 'ACC_16Rnd_9x19_Wist_Mag';

this addweapon 'ACC_Wist_94';

this addPrimaryWeaponItem 'FHQ_acc_ANPEQ15';

this addPrimaryWeaponItem 'FHQ_optic_HWS_tan';

(uniformContainer this) addItemCargoGlobal ['x39_bandage', 2];

(uniformContainer this) addItemCargoGlobal ['x39_epinephrine', 4];

(uniformContainer this) addItemCargoGlobal ['ACC_16Rnd_9x19_Wist_Mag', 2];

(vestContainer this) addItemCargoGlobal ['x39_bandage', 5];

(vestContainer this) addItemCargoGlobal ['x39_morphine', 5];

(vestContainer this) addItemCargoGlobal ['x39_epinephrine', 5];

(vestContainer this) addItemCargoGlobal ['SmokeShellGreen', 9];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl_T', 4];

(vestContainer this) addItemCargoGlobal ['ACC_30Rnd_556x45_Beryl', 4];

(backpackContainer this) addItemCargoGlobal ['x39_medikit5', 3];

(backpackContainer this) addItemCargoGlobal ['x39_bloodbag', 8];

(backpackContainer this) addItemCargoGlobal ['x39_defibrillator', 1];

(backpackContainer this) addItemCargoGlobal ['x39_tourniquet', 2];

(backpackContainer this) addItemCargoGlobal ['x39_bandage', 20];

(backpackContainer this) addItemCargoGlobal ['x39_morphine', 15];

(backpackContainer this) addItemCargoGlobal ['x39_epinephrine', 19];

this linkItem 'ItemMap';

this linkItem 'ItemCompass';

this linkItem 'ItemWatch';

this linkItem 'tf_anprc152_3';

this linkItem 'Binocular';

So as you see above I get far less code lines and script is lightweigh that way. I can of course make those edits myself which doesn't take long, but I would like script to do it for me. Any one can point me how to do that?

Share this post


Link to post
Share on other sites

Whenever I run this it gives me remove all weapons remove all whatever but not the actual gear. It worked one time yesterday but have been unable to replicate since.

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  

×