Jump to content
Sign in to follow this  
metalhead897

Breaking a Loop when another Script activates

Recommended Posts

I Searched OFPEC and here and can't find a damn thing about this (I really don't have time to look hard enough). Basically, i have a simple script that repeats an animation loop so that they don't get up and change animations.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#loop1

guy1 switchmove "sitting1";

guy2 switchmove "crouchrest";

guy3 switchmove "effectstandsitdown";

guy4 switchmove "standrest";

~5

//Repeats this part again 3 times

However I'm not great with C++ im still learning it. So I don't know the syntax to break this loop, when another script becomes active. I want this script to exit when another is active, so that they change animation and move about ( i have all the waypoints and such set up) and get in position when they are attacked.

Assume the other script is called "scramble.sqs", and #FormUp is the function inside that script.

I tried <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(FormUp = TRUE): goto "exit"

exit

and

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#FormUp

goto Loop1exit

....

Share this post


Link to post
Share on other sites

Got to put a condition in.

In your first script have something like this within the loop, at the start usually or wherever you need it.

? BreakLoop : GoTo "Exit"

At the bottom of your script have this,

#Exit

Exit

In your new script you meet the condition.

Breakloop = True

That's it.

Share this post


Link to post
Share on other sites
...

You Could try: [] execVM "swmove.sqf";

content of swmove.sqf:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_run"];

_run=true;

while{_run} do

{

   while{_run} do

   {

       guy1 switchmove "sitting1";

       guy2 switchmove "crouchrest";

       guy3 switchmove "effectstandsitdown";

       guy4 switchmove "standrest";

       sleep 5;

       if(FormUp)then{_run=false;};

   };

};

I nested the while loop in another while loop, because of the fact that while loops terminate after 10.000 cycles, just in case smile_o.gif

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
Sign in to follow this  

×