Jump to content
Sign in to follow this  
ramiroxd1

How to attach accessories to the weapon of a unit in the config.cpp?

Recommended Posts

How to attach accessories to the weapon loadout in a unit that I am creating in the config.cpp?

I want to create a unit by a config.cpp, but I do not know what code to use to place the weapon accessories, please help me!

class CfgVehicles

{

class I_soldier_TL_F; //

class ExampleUnit : I_Soldier_TL_F //Unit Class name: Class getting info from

{

side = 2; //

faction = "exampefaction"; //Your Faction

backpack = "-"; //Backpack

vehicleclass = "examplegroup"; //Unit Group

_generalMacro = "I_Soldier_TL_F"; //Class Name

scope = 2;

displayName = "ExampleUnit"; //In-Game Name

weapons[] = {"hlc_rifle_Bushmaster300","hgun_Rook40_F","Throw","Put","Binocular"};

respawnWeapons[] = {"hlc_rifle_Bushmaster300","hgun_Rook40_F","Throw","Put","Binocular"};

magazines[] = {"29rnd_300BLK_STANAG","29rnd_300BLK_STANAG"};

respawnMagazines[] = {"29rnd_300BLK_STANAG","29rnd_300BLK_STANAG"};

cost = 300000;

threat[] = {1,0.7,0.3};

items[] = {"FirstAidKit"};

linkedItems[] = {"V_I_G_resistanceLeader_F","rhsusf_mich_bare_alt","ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS"};

respawnLinkedItems[] = {"V_I_G_resistanceLeader_F","rhsusf_mich_bare_alt","ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS"};

uniformClass = "exampeuniform"; //uniform you are using

camouflage = 1.6;

};

Share this post


Link to post
Share on other sites

You have to create a new weapon, with the code listed below, using the accessories that you want, and then give that weapon to the unit. Given my example, your new code would be:

weapons[] = {"myNewWeapon","hgun_Rook40_F","Throw" ,"Put","Binocular"};

respawnWeapons[] = {"myNewWeapon","hgun_Rook40_F","Throw" ,"Put","Binocular"};

class cfgWeapons {

class hlc_rifle_Bushmaster300;

class myNewWeapon : hlc_rifle_Bushmaster300 {
	scope = 1;
	class LinkedItems {

		class LinkedItemsOptic {
			slot = "CowsSlot";
			item = "opticClassName";
		};

		class LinkedItemsAcc {
			slot = "PointerSlot";
			item = "pointerClassName";
		};

		class LinkedItemsMuzzle {
			slot = "MuzzleSlot";
			item = "muzzleClassName";
		};

		class LinkedItemsUnder {
			slot = "UnderBarrelSlot";
			item = "bipodClassName";
		};
	};
};
}

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks man, works perfect!!, Do you know how I can add items, magazines, etc., to the backpack? because its forever empty, Greetings

Share this post


Link to post
Share on other sites

Backpacks work almost the same way, in that you have to create a 'new' backpack class name, and give it whichever items you need.

class base_backpack_class;

class new_backpack : base_backpack_class {
	scope = 1;
	class TransportItems {

		class _xx_medikit {
			name = "medikit";
			count = 1;
		};

		class _xx_toolkit {
			name = "toolkit";
			count = 1;
		};
	};
	class TransportMagazines {

		class _xx_myMagazine {
			magazine = "myMagazine";
			count = 1;
		};
	};
};

The medikit and toolkit code I copied from an old post I made. The Transportmagazines portion I did from memory (since I'm not at home to verify) so it could have an error. I think there's also a TransportWeapons, and a TransportBackpacks (which would be used for ammo crates). The same method is used to add inventory to ammo boxes, backpacks and vehicles.

Edited by BadHabitz
  • Like 1

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  

×