Jump to content
cybercoco

Trying to create an item in "class CfgMagazines"

Recommended Posts

Hi all,

 

I would like to create a new item, I looked at this post  and tried it, but failed...

 

mod file is @test, in there I have mod.cpp and test.pbo. In test.pbo I have :

 

config.cpp

class CfgPatches
{
    class test
    {
        units[]={};
        weapons[]={};
        requiredVersion=1;
    };
};

class CfgMagazines
{
    class CA_Magazine;
    class the_antibiotic: CA_Magazine
    {
        displayName = "Antibiotic";
        scope=2;
        picture = "antibiotic.paa";
        model="\A3\structures_f_epa\Items\medical\antibiotic_F";
	};
};

and antibiotic.paa

 

In the main screen I can see that my mod has been loaded (the logo appears).

After, in the editor, I place a unit with :

this addMagazines ["the_antibiotic", 1];

It doesn't work ...

Share this post


Link to post
Share on other sites

I have tried following this post, but I didn't make it.

I really need help, I'm sure one of you guys knows how to do that.

 

Please,

 

Thanks,

C.Coco

Share this post


Link to post
Share on other sites

Have you checked the config viewer to see if your item was actually created?

 

Here's what I did ( I am also faily new to creating config stuff as you might have noticed from the other post)

class CfgMagazines
{
    class CA_Magazine; //class to inherit from
    class Revo_mD_flag: CA_Magazine //create new class and inherit all values from CA_magazine
    {
        author = "Revo";  //Set author name
        displayName = $STR_mD_flag; //name from stringtable.xml
        model = "\A3\Signs_F\SignSpecial\FlagSmall_F.p3d"; //the model
        count = 1; //no clue :D
        scope = 2; //available in editor
        mass = 10; //weight of the object
        picture = "\Revo_mineDetector\images\flag_icon.paa"; //inventory picture
        descriptionShort = $STR_mD_flagDesription; //description from stringtable.xml
    };
};

Works like a charm.

this addMagazines ["the_antibiotic", 1];

Use addItem, that works for me.

 

 

 

Edit: Corrected wrong information about scope and mass

Share this post


Link to post
Share on other sites

Thank you for the reply, however it didn't work.

Here's the structure :

 

@NRD_Items

     - mod.cpp

     - NRD_Items.pbo

          - config.cpp

          - item_olives.paa

 

config.cpp

class CfgMagazines
{
    class CA_Magazine;
    class nrd_item_olives: CA_Magazine
    {
        author = "Coco";
        displayName = "nrd_item_olives";
        model = "\A3\weapons_F\ammo\mag_univ.p3d";
        count = 1;
        scope = 2;
        class ItemInfo
            {
                    mass = 2;
            };
        picture = "\NRD_Items\item_olives.paa";
        descriptionShort = "des";
    };
};

I can't see what's wrong with that code... And ingame when I do :

this additem "nrd_item_olives";

I don't get anything in my inventory.

Share this post


Link to post
Share on other sites

Does it appear in the config viewer in cfgMagazines?

Share this post


Link to post
Share on other sites

Does it appear in the config viewer in cfgMagazines?

No I don't find "nrd_item_olives" under CfgMagazine...

There must be a problem, but I can't figure it out.

 

Is that the correct structure ?

@NRD_Items

     - mod.cpp

     - NRD_Items.pbo

          - config.cpp

          - item_olives.paa

Share this post


Link to post
Share on other sites

the pbo is in an folder called addons right? Because you didn't mentioned that in your structure.

Share this post


Link to post
Share on other sites

Indeed, I didn't mention it, but even with the "addons" folder :

 

Structure :

 

@NRD_Items

     - mod.cpp

     - addons

          - NRD_Items.pbo

               - config.cpp

               - item_olives.paa

 

config.cpp

class CfgMagazines
{
    class CA_Magazine;
    class nrd_item_olives: CA_Magazine
    {
        author = "Coco";
        displayName = "nrd_item_olives";
        model = "\A3\weapons_F\ammo\mag_univ.p3d";
        count = 1;
        scope = 2;
        mass = 2;
        picture = "\NRD_Items\item_olives.paa";
        descriptionShort = "des";
    };
};

Ingame

this additem "nrd_item_olives";

Share this post


Link to post
Share on other sites

After several other desperate attempts, I still can't figure out how to make it work ....

I am packing my files with BIS tool : Filebank. The object I'm trying to create doesn't appear in the Cfg during mission.

 

Can someone please call in The Jedi High Council ?

 

C.Coco

Share this post


Link to post
Share on other sites

Why not use addonBuilder ? Maybe that's the issue.

  • Like 1

Share this post


Link to post
Share on other sites

Why not use addonBuilder ? Maybe that's the issue.

 

It doesn't work :

Build failed, result code = 1073741515
Binarize task failed

...

Share this post


Link to post
Share on other sites

did you include class cfgPatches in your config.cpp? Also you wouldn't need binarization so try without binarizing.

Share this post


Link to post
Share on other sites

Even after unchecking "binarize", it doesn't work and shows the same error message.

I'm re-installing the Arma 3 Tools...

Share this post


Link to post
Share on other sites

Packing NRD_Items into NRD_Items.pbo worked  :D  ! But the item is not created :( .

 

Is this the correct way to do it ?

 

Structure :

 

@NRD_Items

     - mod.cpp

     - addons

          - NRD_Items.pbo

               - config.cpp

               - item_olives.paa

 

config.cpp

class cfgMagazines
{
    class CA_Magazine;
    class rb_antibiotic: CA_Magazine
    {
        mass=1;
        scope=2;
        author="Nono";
        displayName="Antibiotic";
        picture = "\NRD_Items\item_olives.paa";
        model="\A3\structures_f_epa\Items\medical\antibiotic_F";
    };
};

Ingame

this additem "rb_antibiotic";

Share this post


Link to post
Share on other sites

Looks alright. Is does the config entry exists?

Share this post


Link to post
Share on other sites

It's all strange...

 

I took some files from a different mod, and it works. This is config.cpp

class CfgPatches
{
	class scorch_invitems
	{
		units[] = {"scorch_invitems"};
		weapons[] = {};
		requiredVersion = 1.0;
	};
};

class CfgWeapons
{
	class ItemWatch;
	class sc_bandage: ItemWatch
	{
		displayName = "Bandage";
		count = 1;
		class ItemInfo
        	{
            		mass = 1;
        	}; 
		picture = "\scorch_invitems\images\bandage.paa";
		model="\A3\structures_f_epa\Items\medical\antibiotic_F";
		descriptionShort = "";
	};

However the author has set it to the "ItemWatch", I need it to be a inventory item, like the FAK.

Do I change "ItemWatch" with "FirstAidKit" ?

Share this post


Link to post
Share on other sites

The config.cpp was missing CfgPatches because while I was trying without it it didn't work.

Final code :

class CfgPatches
{
    class testinggear
    {
        units[] = {"testinggear"};
        weapons[] = {};
        requiredVersion = 1.0;
    };
};

class cfgMagazines
{
    class CA_Magazine;
    class sc_bandage: CA_Magazine
    {
		displayName = "Bandage";
		count = 1;
		class ItemInfo
        	{
            		mass = 1;
        	}; 
		picture = "\testinggear\images\bandage.paa";
		model="\A3\structures_f_epa\Items\medical\antibiotic_F";
		descriptionShort = "Hey Wonno";
	};
};

Share this post


Link to post
Share on other sites

However the author has set it to the "ItemWatch", I need it to be a inventory item, like the FAK.

Do I change "ItemWatch" with "FirstAidKit" ?

 

 

Inherhit from ItemCore then.

Share this post


Link to post
Share on other sites

Inherhit from ItemCore then.

I actually used class cfgMagazines and removed ItemWatch.

It's now working properly !

 

But I don't understand the use of this part :

class CfgPatches
{
    class testinggear
    {
        units[] = {"testinggear"};
        weapons[] = {};
        requiredVersion = 1.0;
    };
};

Does it create a new class ?

Share this post


Link to post
Share on other sites

did you include class cfgPatches in your config.cpp? Also you wouldn't need binarization so try without binarizing.

 

The issue came from the fact that I had the game opened while I was trying to pack it.

When I pack the folder with the game closed, it works.

Share this post


Link to post
Share on other sites
mass = 10; //weight of the object

 

That sets the number of "slots" it's going to take in the inventory, right ?

I don't understand, because when I set it to 20, it doesn't make any difference !

Share this post


Link to post
Share on other sites

It's the weight not slots, but if you want to have exactly 500 gramm you would need to calculate that.

 

The reason why it doesn't work for you is, because you are defining it in the class ItemInfo, just put it into your main class.

Share this post


Link to post
Share on other sites

Ok, i deleted the class ItemInfo.

If I set the mass to 100, will it take more space in the unit's backpack ?

Share this post


Link to post
Share on other sites

Yep, that's how it works.

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

×