Home   Help Search Login Register  

Author Topic: How to delay a scripted action?  (Read 2147 times)

0 Members and 1 Guest are viewing this topic.

Offline Jester_UK

  • Members
  • *
How to delay a scripted action?
« on: 06 Mar 2007, 02:21:38 »
Hi all.

Very likely a simple question (I hope). I have a small script with the following lines in it:

a2 action["GETOUT",bus1]; unassignvehicle a2;
a3 action["GETOUT",bus1]; unassignvehicle a3;
a4 action["GETOUT",bus1]; unassignvehicle a4;
a5 action["GETOUT",bus1]; unassignvehicle a5;

Etc

The script is saved as .sqs format.

"a2" - "a4" are AI infantry squad members, "bus1" is a Black Hawk.

At the moment when the script runs all the AI infantry disembark from the Black Hawk in a mass group. What I want is to delay each statement's operation so that the infantry exit the helicopter one at a time. I tried the "~" command followed by the number of seconds, also tried the "sleep" command (even though that's apparantly only for .sqf files), but no matter how I set up the syntax it returns an error on testing ingame (all the infantry still exit the Black Hawk, but still do so simultaneously).

Can someone show me where the correct sleep command would fit into the above script section if for example I wanted a 1 second delay between each infantryman exiting the helicopter?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: How to delay a scripted action?
« Reply #1 on: 06 Mar 2007, 08:24:45 »
Odd..
~ should work just fine..
And when testing your scenario I get no errors myself.

How did you execute the script; did you use exec or execVM?
What's the error message?
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Jester_UK

  • Members
  • *
Re: How to delay a scripted action?
« Reply #2 on: 06 Mar 2007, 10:45:17 »
I've tried running it with both exec and execVM. I've also now tried running it in both .sqs and .sqf format.

In .sqs using the exec command in the trigger "on act" line it works fine with no errors if I don't add the delay commands to the script (but of course all the AI disembark simultaneously).

I've tried starting lines2,3 and 4 with the ~delay time (eg ~2; at the start of line 2  etc) and tried putting the delay between each statement, as seems to be suggested in the Wiki like this:

a2 action["GETOUT",bus1]; unassignvehicle a2;
~2;
a3 action["GETOUT",bus1]; unassignvehicle a3;
~4;
a4 action["GETOUT",bus1]; unassignvehicle a4;
~6;
a5 action["GETOUT",bus1]; unassignvehicle a5;

In sqs format any addition of the ~ statement returns an error (black box in top left of the screen when the script is called ingame) that just quotes a part of the script and says "Generic error." The script will still run but the AI will all exit the helicopter simultaneously.

In sqf format, if I can get it to run at all, the code error box is far larger and usually only the first AI infantryman (the one who's line has no delay) will disembark. Unfortunately the error box disappears before I can note down the error message. (as per the content of the Wiki, in sqf format I change the "~" to "sleep").


I should have mentioned in my original post that I'm totally new to the editor, only having had ArmA since the UK release. I suspect I'm doing something really stupid here.

Offline FreeBird

  • Members
  • *
Re: How to delay a scripted action?
« Reply #3 on: 06 Mar 2007, 11:14:12 »
Code: [Select]
a2 action["GETOUT",bus1]; unassignvehicle a2;
sleep 2;
a3 action["GETOUT",bus1]; unassignvehicle a3;
sleep 4;
a4 action["GETOUT",bus1]; unassignvehicle a4;
sleep 6;
a5 action["GETOUT",bus1]; unassignvehicle a5;

is ok for sqf,

but for sqs try this;

Code: [Select]
a2 action["GETOUT",bus1]; unassignvehicle a2
~2
a3 action["GETOUT",bus1]; unassignvehicle a3
~4
a4 action["GETOUT",bus1]; unassignvehicle a4
~6
a5 action["GETOUT",bus1]; unassignvehicle a5
Call [This,Birth,School,Work,Death]execVM "Storyofmylife.sqf"
(_this select 1)ObjStatus "DONE";(_this select 2)ObjStatus "DONE";(_this select 3)ObjStatus "ACTIVE";(_this select 4)ObjStatus "HIDDEN";
if not((_this select 0) IsKindOf "Human")ExitWith{PlayMusic"Goodbye Cruel World"}

Offline Jester_UK

  • Members
  • *
Re: How to delay a scripted action?
« Reply #4 on: 06 Mar 2007, 11:33:22 »
Thanks, Freebird.

Working 100% now. Too many semi colons in the sqs script.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: How to delay a scripted action?
« Reply #5 on: 06 Mar 2007, 11:45:51 »
Ah, I see..
If you have semicolon after the ~2 you will get an error..
I now vaguely remember this same thing happening in OFP :scratch:

Otherwise semicolons don't matter in sqs scripts, when I tested that script I had the semicolons there but not after the ~2 delays..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Jester_UK

  • Members
  • *
Re: How to delay a scripted action?
« Reply #6 on: 06 Mar 2007, 12:18:53 »
Yeah, sorry h-,

Like I said in my previous post I'm totally new to this and should have said so in my original post. If I had you may well have twigged what I was doing wrong from the outset.

Being a newbie I'm sure I'll come up with loads more questions that'll leave you wondering what the heck I'm smoking!!  :D

Thanks for the quick responses.