Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Mysteryman5150

weapon array question

Recommended Posts

Does anyone know if it is possible to have 2 weapon assignment lines on one unit, i.e. see below:

CFG****

{

class ***** : *****

{

weapons [] = { *****, *****, *****};

weapons [] = { *****};

};

};

I know it doesn't make much sense to do this but I am wanting to make the program look to an outside sourcefor a specific weapon and I think it may need it's own line to do so.

Share this post


Link to post
Share on other sites

Got a possible workaround in mind but could you prior elaborate what your goal ist with this? Just to make sure i'm not leading to the wrong track.

Share this post


Link to post
Share on other sites

Myke- I am thinking of making a mod that would allow the user to redifne the main weapon layouts of soldiers. Therefore what I need to do is remove the existing weapon and replace it with a modifier that would make the game look to another source to find the weapon input. I have sort of made it work with one weapon {} = line but I do get an error message when loading it.

The line I made goes something like this

weapons {} = {_look_to_file, "M9", "NV_Goggles",}

That is not the exact line, just and example of how I did it. Like I said it did work just that I recieved an error message. I found that using 2 weapon {} = lines did not work so I have been working with the one line idea for now.

Share this post


Link to post
Share on other sites

Ok, first let me point to a synthax error you have there, Wrong brackets before the equal sign, correct is:

weapons [] = {};

But this just as a sidenote. Now about your specific problem. As not everyone knows, you're not limited to BIS standard definitions in a config but you may also define your own, although those will not be used by the game by default.

For your purpose, i guess in the regular weapons array, defining those weapons and/or items that should be equal on all variations is a start. So lets say, add binocs and NVgoggles to the weapons array. You may also leave it empty, up to you.

Now to get your variations, you define your own config value:

Mman5150_weapons [] = {};

Okay, now it's defined, but how to access it? By scripting.

In a script, use now this line to read out the weapons:

_myWeapons = getArray (configFile >> "cfgVehicles >> typeof _unit >> "Mman5150_weapons")

This reads the config value of your own defined config entry. From here, you may treat it as simple script and do whatever you want it to do. Select by random, by time of day, by rank or whatever comes to your mind.

And to get it started by default, add the script to a init eventhandler in the config so no manual call of the script is needed.

Also be aware that you may use nested arrays:

Mman5150_weapons [] = {{"PrimaryWeaponClass1", "PrimaryMagazineClass1"}, {"PrimaryWeaponClass2", "PrimaryMagazineClass2"}};

Now each subarray holds a complete set (add there to fill up the space as you see fit) which you can select from by the above introduced method.

Hope this get you started. If still things are unclear, just ask.

Share this post


Link to post
Share on other sites

Thanks Myke. In my config file the [] = {} was correct. I just mistyped it on the post:o.

That info may be helpful in more than just the mod I was asking about. Right now I am working on a few mods so I may give this idea a shot when I come back to this mod.

Thanks again:)

Share this post


Link to post
Share on other sites
Sign in to follow this  

×