Results 1 to 4 of 4

Thread: Breaking a Loop when another Script activates

  1. #1
    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 &#34;sitting1&#34;;
    guy2 switchmove &#34;crouchrest&#34;;
    guy3 switchmove &#34;effectstandsitdown&#34;;
    guy4 switchmove &#34;standrest&#34;;
    ~5
    //Repeats this part again 3 times
    [/QUOTE]

    However I&#39;m not great with C++ im still learning it. So I don&#39;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">?&#33;&#40;FormUp = TRUE&#41;&#58; goto &#34;exit&#34;
    exit[/QUOTE]
    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
    ....[/QUOTE]

  2. #2
    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&#39;s it.
    James Andrew Wilkinson 1977 - 2005 R.I.P.


    http://www.freewebs.com/ofpbob/index.htm

  3. #3
    Thanks for that, all works fine now.

  4. #4
    Quote Originally Posted by (metalhead897 @ Jan. 02 2007,00:10)
    ...
    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 &#91;&#34;_run&#34;&#93;;
    _run=true;
    while{_run} do
    {
    *** ***while{_run} do
    *** ***{
    *** *** *** ***guy1 switchmove &#34;sitting1&#34;;
    *** *** *** ***guy2 switchmove &#34;crouchrest&#34;;
    *** *** *** ***guy3 switchmove &#34;effectstandsitdown&#34;;
    *** *** *** ***guy4 switchmove &#34;standrest&#34;;
    *** *** *** ***sleep 5;
    *** *** *** ***if&#40;FormUp&#41;then{_run=false;};
    *** ***};
    };
    [/QUOTE]
    I nested the while loop in another while loop, because of the fact that while loops terminate after 10.000 cycles, just in case



    A.C.E. Advanced Combat Environment

    Dev-Heaven.net Free Project Hosting | A2 Community Issue Tracker Help BIS, Help yourself!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •