Jump to content

Recommended Posts

Hello!
 
This is not exactly a problem. I wan't to make my scripts as short as possible and at the moment my script is in 11 different .sqf files.
 
Is there any way to bring these scripts into one .sqf that will be launched from init.sqf

 
 

 
I'll make short example so it's easier to modify.

(You cannot bring the arsenal back after you remove it with this script, this is just example)

Init.sqf

[] execVM "addActions\addaction_0.sqf";

addActions\addaction_0.sqf


add_menu = name_unit AddAction ["<t color=""#4DB0E2"">" +"Bnae's menu", "addActions\addaction_1.sqf"];

addActions\addaction_1.sqf


name_unit removeAction add_menu;
add_arsenal = name_unit AddAction ["<t color=""#0DFF00"">" +"Add arsenal", "addActions\addaction_2.sqf"];

addActions\addaction_2.sqf


name_unit removeAction add_arsenal;

arsenal = ["AmmoboxInit",[arsenal_box,true]] spawn BIS_fnc_arsenal;

remove_arsenal = name_unit AddAction ["<t color=""#FF0000"">" +"Remove arsenal", "addActions\addaction_3.sqf"];

addActions\addaction_3.sqf


removeAllActions arsenal_box;

name_unit removeAction remove_arsenal;

add_arsenal = name_unit AddAction ["<t color=""#0DFF00"">" +"Add arsenal", "addActions\addaction_2.sqf"];

Share this post


Link to post
Share on other sites


//init.sqf
call compile preprocessfilelinenumbers "actionSelector.sqf"


//actionSelector.sqf
BNAE_fnc_actionsSelector =
{
    params ["_action"];
// maybe it might also be _this select 3. Didn't use addaction in a while

    switch (_action) do
    {
        case 1:
        {
            // execVM "addActions\addaction_1.sqf";
            // or just copy and paste the content of addaction_1
        };
        case 2:
        {
            // execVM "addActions\addaction_2.sqf";
            // or just copy and paste the content of addaction_2
        };
        //etc    
    }
}
//addAction
add_arsenal = name_unit AddAction ["<t color=""#0DFF00"">" +"Add arsenal", {[2] call fnc_actionSelector}];


 

 

one of many solutions

Share this post


Link to post
Share on other sites

 

//init.sqf
call compile preprocessfilelinenumbers "actionSelector.sqf"


//actionSelector.sqf
BNAE_fnc_actionsSelector =
{
    params ["_action"];
    // maybe it might also be _this select 3. Didn't use addaction in a while

    switch (_action) do
    {
        case 1:
        {
            // execVM "addActions\addaction_1.sqf";
            // or just copy and paste the content of addaction_1
        };
        case 2:
        {
            // execVM "addActions\addaction_2.sqf";
            // or just copy and paste the content of addaction_2
        };
        //etc    
    }
}
//addAction
add_arsenal = name_unit AddAction ["<t color=""#0DFF00"">" +"Add arsenal", {[2] call fnc_actionSelector}];
 
 
one of many solutions

 

 

Thank you for fast reply and excellent solution. Just the thing i was looking for!

Share this post


Link to post
Share on other sites

Unfortunately i cannot get this working at all.

Mostly because i don't know how it works.

add_arsenal = name_unit AddAction ["<t color=""#0DFF00"">" +"Add arsenal", {[2] call fnc_actionSelector}];

What does that [2] stand for? I assume that it will read the "case 2:"

And why it's only "fnc_actionSelector" and the other one is "BNAE_fnc_actionsSelector"?

Share this post


Link to post
Share on other sites
What does that [2] stand for? I assume that it will read the "case 2:"

 

2 is given to the BNAE_fnc_actionSelector. The function checks the input and compares it to the cases. so here the second case is the number 2 and the inpput is also 2. so the second case is selected.

 

And why it's only "fnc_actionSelector" and the other one is "BNAE_fnc_actionsSelector"?

 

because i forgot to change it ^^

it should be the same function. name it as u wish.

 

 

just check if your "addaction_0.sqf" etc don't have sleep in them. if yes use "[x] spawn fnc_actionSelector" instead of  "[x] call fnc_actionSelector"

  • Like 1

Share this post


Link to post
Share on other sites

2 is given to the BNAE_fnc_actionSelector. The function checks the input and compares it to the cases. so here the second case is the number 2 and the inpput is also 2. so the second case is selected.

because i forgot to change it ^^

it should be the same function. name it as u wish.

 

 

just check if your "addaction_0.sqf" etc don't have sleep in them. if yes use "[x] spawn fnc_actionSelector" instead of  "[x] call fnc_actionSelector"

 

Okay, thanks for clearing this up.

I'm trying to make this work in bigger scale so i'll hope i can make it.

Share this post


Link to post
Share on other sites

Dont know if your interested in THIS if your trying to accomplish a addAction menu system.

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

×