Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
evans d [16aa]

Setting a Boolean Variable in addAction

Recommended Posts

Ok, I have a script and I want it to loop until a variable is set to true.

My variable is called "free".

My script goes like this:

civilian.sqf

#anim

civ1 disableAI "Move";
civ2 disableAI "Move";
civ3 disableAI "Move";
civ4 disableAI "Move";
civ5 disableAI "Move";

civ1 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
civ2 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Ohara";
civ3 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Cooper";
civ4 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Rodriguez";
civ5 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";

? free == true: goto "freed"

sleep 130;

goto "anim"


#freed

civ1 switchMove "";
civ2 switchMove "";
civ3 switchMove "";
civ4 switchMove "";
civ5 switchMove "";

civ1 enableAi "MOVE"
civ2 enableAi "MOVE"
civ3 enableAi "MOVE"
civ4 enableAi "MOVE"
civ5 enableAi "MOVE"

I'm just not sure how the addAction code looks, or even if my syntax is correct, I butchered a camera code file.

Many thanks,

Bashkire.

Share this post


Link to post
Share on other sites

The synthax is messed up between sqs and sqf style. sqf doesn't support goto command.

_civs = [civ1, civ2, civ3, civ4, civ5];
{_x disableAI "Move"} foreach _civs;
while {!free} do {
civ1 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
civ2 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Ohara";
civ3 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Cooper";
civ4 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Rodriguez";
civ5 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
sleep 130;
};
{_x switchMove "";_x enableAI "Move";} foreach _civs;

Share this post


Link to post
Share on other sites

Gotcha, so how do I make "free" true? I've tried putting "free == true" and "free = true" in my addAction line but it's rejecting it.

Share this post


Link to post
Share on other sites

== is comparison, = is assignment.

Therefore:

free = true;

This line has to be in the script that the action executes.

Share this post


Link to post
Share on other sites

Ah, I see. I was putting it in the actual line. Now I get the feeling that I'm meant to declair free as a variable. Would that be

setPublicVariable free = false;

Share this post


Link to post
Share on other sites

asuming you use Mykes example, add this line to either yourself or an object:

_myAction = unit_or_object_name addAction ["text for what youll see in action menu", "myscript.sqf"]

and this is myscript.sqf:

free=true;

make sure that you set free=false in init.sqf or somewhere trigger etc on mission start.

Share this post


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

×