Home   Help Search Login Register  

Author Topic: The "#sleep 1;" error  (Read 1455 times)

0 Members and 1 Guest are viewing this topic.

Offline L!nk

  • Members
  • *
The "#sleep 1;" error
« on: 02 Mar 2008, 15:13:57 »
This error happens a few seconds into my mission (#sleep 1;) and it selects a random sleep command in random files.

It has a major LAG effect and I get a CTD when I retry this mission.

The error also happens when I save the mission after I tried it.

The only way to stop it is to restart ArmA.

I only use .sfq syntax. Recently converted my skills from .sqs (this is possibly a issue)

All my scripts run fine and everyting works perfectly except for this one.

Read my http://www.ofpec.com/forum/index.php?topic=31021.0 topic for a quote for how I use .sqf scripting.
« Last Edit: 02 Mar 2008, 15:28:11 by L!nk »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: The "#sleep 1;" error
« Reply #1 on: 02 Mar 2008, 16:01:49 »
Quote
Recently converted my skills from .sqs (this is possibly a issue)
Quite possible, I recently had the same problem with sqs scripts I used in OFP converted to sqf for ArmA.
The problem was that even though going through the scripts several times there were one or two occations where I had forgot to change exec to execVM which caused the problem.

Maybe it's the same in your case :dunno:
« Last Edit: 02 Mar 2008, 16:08:14 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: The "#sleep 1;" error
« Reply #2 on: 02 Mar 2008, 18:50:50 »
Make sure all your sleeps are actually sleeps : I keep mixing up my sleep 1; and ~1 if I happen to be in the middle of a conversion process. That sometimes causes problems.  :dunno: Also make sure as h- said that you're execvm'ing the .sqf properly!

Otherwise, we'll need a more complete quote of the code used to find the problem.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline L!nk

  • Members
  • *
Re: The "#sleep 1;" error
« Reply #3 on: 02 Mar 2008, 19:10:16 »
Thats the thing. All of my scripts work perfectly. This isn't my first mission I made with .sfq files.

I recently started to use this type of coding methods. I call it Global functions...

Code: [Select]
hint "file lproccesed";

Link_RandomNum =
{
     _max = _this select 0;
     _min = _this select 1;

     while {player alive} do
     {
          sleep 1; // this is usually where I get my errors
          _num = (_min + (random _max));
          hint format ["%1",_num];
     };
     while {!(alive player)} do
     {
          sleep 1; // this is usually where I get my errors
     };
     [_max,_min] call Link_RandomNum;
};

This script is called like this:

Code: [Select]
[] execVM "file.sqf"; // first procces the file
sleep 1;
[10,2] call Link_RandomNum; // call a script in the file

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: The "#sleep 1;" error
« Reply #4 on: 02 Mar 2008, 22:14:27 »
Use Spawn instead of call -> can't normally have sleeps inside scripts called with call.  :good:

*waits for Mandoble & co. to come storming in with their objections*

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: The "#sleep 1;" error
« Reply #5 on: 02 Mar 2008, 22:44:48 »
I already replied with a code example in a different thread  :whistle:

Offline L!nk

  • Members
  • *
Re: The "#sleep 1;" error
« Reply #6 on: 03 Mar 2008, 17:53:43 »
I know, but them I asked you a question on it.

Why "spawn" and why "isNil" command.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: The "#sleep 1;" error
« Reply #7 on: 03 Mar 2008, 20:55:02 »
spawn executes the provided code in parallel, calling script is not stopped while with call command the parent script is stopped until call code returns.

isNil checks whether the provided variable is already defined or not. In your case, the code variable is global, so you dont need to define it over and over each time the script is executed.