Home   Help Search Login Register  

Author Topic: Easy SQF question.  (Read 1766 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Easy SQF question.
« on: 16 Dec 2008, 22:08:53 »
Hi everyone,

I have this sqf going:

Code: [Select]
_body = _this select 0;
_fly  = _this select 1;

while {true} do
{
   if (_fly distance _body > 3) then
{
       _fly setpos getpos _body;
} else {
       _fly setpos [(getpos _fly select 0) + (0.1 - random 0.2) , (getpos _fly select 1) + (0.1 - random 0.2), (getpos _fly select 2) + (0.1 - random 0.2)];
   };
   sleep 1;
};

I get this errormessage:

Quote
#sleep 1

error generic error in expression

Someone probably laughs at me, but I have no idea what is wrong.

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Ext3rmin4tor

  • Members
  • *
Re: Easy SQF question.
« Reply #1 on: 16 Dec 2008, 22:13:17 »
It seems correct... Did you copy/pasted the code from the original one or rewrite it?
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Easy SQF question.
« Reply #2 on: 16 Dec 2008, 22:14:40 »
It's copied and pasted.
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Ext3rmin4tor

  • Members
  • *
Re: Easy SQF question.
« Reply #3 on: 16 Dec 2008, 22:16:28 »
Is the error displayed immediately or after some time? Because I remember that a While-loop has a limitation of 10000 loops before exiting and giving a generic expression error. Anyway now I try it on a test map.

EDIT: I tried and it works for me (no error displayed). Are you sure you passed the script correct parameters? In which context are you using it?
« Last Edit: 16 Dec 2008, 22:20:48 by Ext3rmin4tor »
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Easy SQF question.
« Reply #4 on: 16 Dec 2008, 22:22:09 »
I have an effect with flies in a mission, it comes in two scripts.

deadguy is unit named that (it's a corpse)
That script is run when a player enters a trigger.
OnActivation [deadguy] exec "flies.sqs"
The SQF is then run from that script as you can see.

Code: [Select]
_body = _this select 0

_count = 0

#loop

? _count >= 100 : exit
_count = _count + 1

_fly = "HouseFly" createvehicle [(getpos _body select 0) + (2 - random 4), (getpos _body select 1) + (2 - random 4), random 2]
_fly setdir random 360
[_body,_fly] exec "randomfly.sqf"
_fly = ObjNull

~ 0.01

goto "loop"

Laggy
« Last Edit: 16 Dec 2008, 22:27:41 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Ext3rmin4tor

  • Members
  • *
Re: Easy SQF question.
« Reply #5 on: 16 Dec 2008, 22:23:08 »
Check the parameters you pass the script (I tested it with a M1A1 and a Harrier flying). Could you tell me the use of the script and what parameters you're passing to it
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Easy SQF question.
« Reply #6 on: 16 Dec 2008, 22:28:29 »
Just modified my last message to answer your questions.
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline i0n0s

  • Former Staff
  • ****
Re: Easy SQF question.
« Reply #7 on: 16 Dec 2008, 22:37:17 »
*cry*
You started a SQF file with exec, so it will get interpreted as a SQS file.
You have to use execVM to get the SQF syntax.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Easy SQF question.
« Reply #8 on: 16 Dec 2008, 22:39:15 »
 :-[

Ehhh, I said someone is laughing at me.
It works now.

Thanks both of you,

Laggy
« Last Edit: 16 Dec 2008, 22:42:58 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline i0n0s

  • Former Staff
  • ****
Re: Easy SQF question.
« Reply #9 on: 17 Dec 2008, 01:54:30 »
:)

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Easy SQF question.
« Reply #10 on: 19 Dec 2008, 11:46:59 »
While on this subject....Could anyone expound on what the VM is in execVM and why it must be there to distinguish SQF? Just for further understanding.  :scratch:

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Easy SQF question.
« Reply #11 on: 19 Dec 2008, 15:00:17 »
Well, ummm, its the name of the command to execute sqf scripts and functions as opposed to the exec command which is for sqs scripts.

ExecVM
or
ExecVM

as opposed to  Exec

No idea what the VM actually means... maybe Virtual Machine, Very Muchly, Van Morrison, Very Meaningless ... take your pick.


Planck
I know a little about a lot, and a lot about a little.

Offline Ext3rmin4tor

  • Members
  • *
Re: Easy SQF question.
« Reply #12 on: 19 Dec 2008, 15:39:20 »
 :D

It's Virtual Machine



#EDIT: No need to quote the entire previous post you're replying to..    h-
« Last Edit: 19 Dec 2008, 21:40:54 by h- »
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!