Jump to content
Nilia

Whitelisted ACE Arsenal via function in Addon

Recommended Posts

Hi,

I'm kinda experienced already with modding of Items, Uniforms and stuff, but I never had to make any functions in ArmA, and I am only beginning to understand it.

I was trying to add a Whitelisted ACE Arsenal to an Ammobox via Function:

So far I have this:

The Structure is (currently) simple: Addons\Arsenal\

The config just utilizes #includes.

cfgPatches.hpp:

class cfgPatches {

    class Nilia_Server_Functions
    {
        units[]={};
        weapons[]={};
        requiredVersion=0;
        requiredAddons[]={};
        version="1.0";
        versionStr="1.0";
        versionAr[]={1,0,0};
        author[]=
        {
            "Nilia"
        };
        authorUrl="";
        magazines[]={};
        ammo[]={};
    };
};

cfgFunctions.hpp

class CfgFunctions {

    class Nilia_Server_Functions
    {
        class Nilia_Server_Functions
        {
            file="\Arsenal\functions";
            class Nilia_Arsenal
            {
                preInit=1;
            };
        };
    };
};

In the functions folder:

fn_Nilia.Arsenal.sqf

if (!isServer) exitWith {};

private _Unit = this;
if (!alive _Unit) exitWith { hint "Arsenal could not be Loaded" };

hint "Arsenal was loaded";

[_Unit,
["Item1","Item2","Item3"

]
]
call ace_arsenal_fnc_initBox;

If I call this function in the init field of an Ammobox (in the 3den Editor)

call fn_Nilia_Arsenal;

The Mission is Loading as it is supposed to be, the hint "Arsenal was Loaded", but the Arsenal is not added to the Ammobox.

(The item1,2,3 are just placeholders for a bunch of Items, the array is confirmed working, when I replace "_Unit" with "Arsenal" and exectVM the Arsenal.sqf in the init field (and name the Ammobox "Arsenal") it is loading properly.)

 

With this function, I want to achieve to load our restricted Arsenal on my Unit's Server in multiple Missions, without having to update every Mission (instead only the Addon), when I add any Items. This Addon is supposed to be running Server Side.

 

Thank you very much for your Help :D


 

 

 

Share this post


Link to post
Share on other sites
On 10/20/2022 at 11:39 AM, Nilia said:

class CfgFunctions {

    class Nilia_Server_Functions
    {
        class Nilia_Server_Functions
        {
            file="\Arsenal\functions";
            class Nilia_Arsenal
            {
                preInit=1;
            };
        };
    };
};

 

This will define a function called Nilia_Server_Functions_fnc_Nilia_Arsenal from the file <Arma Install>\Arsenal\functions\fn_Nilia_Arsenal.sqf

 

Instead...

class CfgFunctions {

    //Project name
    class Nilia_Functions
    {
    	//Prefix for functions ie Nilia_fnc_# (_fnc_ is added automatically between tag and file name see below)
    	tag = "Nilia";
      
        //Category
        class Nilia_Server_Functions
        {
            //Path where script files can be found for all functions defined within this category
            //This should be a relative path from the base of your mod
            file="\Arsenal\functions";
          
            //Name of file minus fn_ prefix. So fn_Arsenal.sqf
            class Arsenal {};
        };
    };
};

Where Project Name and Category have no effect other than where you can find the functions in the functions viewer.

Check your file path, as noted above this should be a relative path from the base of your mod.

Rename your .sqf file to fn_Arsenal.sqf as per the class name above( //Name of file minus fn_ prefix )

Also removed the preInit, as from your description having it run automatically is not the desired behaviour.

This will compile the function tag_fnc_fileName so Nilia_fnc_Arsenal

 

fn_Arsenal.sqf

if (!isServer) exitWith {};

params[ [ "_obj", objNull, [ objNull ] ] ];
if (isNull _obj || { !( alive _obj ) } ) exitWith { hint "Arsenal could not be Loaded" };

[ _obj, [
	"Item1",
	"Item2",
	"Item3"
], true ] call ace_arsenal_fnc_initBox; //true to add arsenal globally

hint "Arsenal was loaded";

 

In the boxes init...

[ this ] call Nilia_fnc_Arsenal;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi, sorry for my late Reply.

I finally got back to ArmA 3 and was able to Test your Solution.

Thank you very much for your help, the Arsenal now behaves as i would expect it to 😄

 

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

×