OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: L!nk on 21 Feb 2008, 17:34:44

Title: Very weird error... Please help!
Post by: L!nk on 21 Feb 2008, 17:34:44
I get a "while loop" error when I run the script for I think 2 minutes. I pops up at the top of my screen while playing.
Inside the "while" loop is: sleep 1;

It reads more or less like this:

"while {(alive player)} # do"
                              ^
                               l
                     here is the problem

It does not specify what type of error it is. I just says "Error" and then the location of the problem. eg. line 27

Driving me crazy....!!! >:(
Please help.
Title: Re: Very weird error... Please help!
Post by: h- on 21 Feb 2008, 17:44:32
Post the whole loop, the problem is inside it most likely.
Title: Re: Very weird error... Please help!
Post by: Tajin on 21 Feb 2008, 18:16:28
Either that, or a missing symbol before it.
So, post a bigger snipplet of the code instead of a single line. (since that one is correct)
Title: Re: Very weird error... Please help!
Post by: L!nk on 21 Feb 2008, 18:50:57
Ok, here is my exact code:
-----------------------------------------------------------------------------------------
while {(alive player) && (player == vehicle player) && (player distance WestMHQ < 50)} do
{
   sleep 1;
};
if (!(alive _unit)) then {hint "player dead"};
if (_unit != vehicle _unit) then {hint "player in vehicle"};
-----------------------------------------------------------------------------------------

:scratch:

and the error:

-----------------------------------------------------------------------------------------
'...yer} && (player distance WestMHQ)} #do
{
sleep 1;
};
if (!(alive _unit)) the...'
Error
File
C:\blah\blah\blah.sqf, line 11
-----------------------------------------------------------------------------------------
When I retry this mission without restarting the game. I get a CTD.
BTW, I tested on ArmaA 1.09Beta and 1.08

thx in advance.
L!nk
Title: Re: Very weird error... Please help!
Post by: L!nk on 01 Mar 2008, 19:57:02
Still have to figured this out. Someone please help. This is preventing me from doing something awesome.

Thx.
L!nk
Title: Re: Very weird error... Please help!
Post by: Planck on 01 Mar 2008, 20:07:16
If your error is indeed on line 11, why does it look like line 1 to us, is there a previous 10 lines we haven't seen yet?


Planck
Title: Re: Very weird error... Please help!
Post by: Mandoble on 01 Mar 2008, 20:45:56
Code: [Select]
while {(alive player) && (player == vehicle player) && ((player distance WestMHQ) < 50)} do
{
   sleep 1;
};
Title: Re: Very weird error... Please help!
Post by: L!nk on 02 Mar 2008, 11:24:49
here is the whole file.
called in this way: [] execVM "filename.sqf"


Code: [Select]
LinkCTI_MHQBuildAction =
{
_actionOptionsObject = objNull;
_actionOptionsID = -1;

if (_actionOptionsID == -1) then {_actionOptionsObject = player; _actionOptionsID = _actionOptionsObject addAction ["MHQ Build Options", "client\ActionMHQBuild.sqf"]};
while {(alive player) && (player == vehicle player) && (player distance WestMHQ < 50)} do
{
sleep 1;
};
if (!(alive _unit)) then {hint "player dead"};
if (_unit != vehicle _unit) then {hint "player in vehicle"};
if (_actionOptionsID != -1) then {_actionOptionsObject removeAction _actionOptionsID; _actionOptionsID = -1};
sleep 1;
call LinkCTI_MHQBuildAction;
};

sleep 1;
call LinkCTI_MHQBuildAction;
Title: Re: Very weird error... Please help!
Post by: Mandoble on 02 Mar 2008, 11:41:46
Try this and read the NOTE:

Code: [Select]
if (isNil "LinkCTI_MHQBuildAction") then
{
LinkCTI_MHQBuildAction =
{
   private["_actionOptionsObject", "_actionOptionsID", "_unit"];
 


   // NOTE: In your script, _unit is undefined so set it to the corresponding value or replace it by player   



   while {true} do
   {
_actionOptionsObject = objNull;
_actionOptionsID = -1;

if (_actionOptionsID == -1) then {_actionOptionsObject = player; _actionOptionsID = _actionOptionsObject addAction ["MHQ Build Options", "client\ActionMHQBuild.sqf"]};
while {(alive player) && (player == vehicle player) && ((player distance WestMHQ) < 50)} do
{
sleep 1;
};
if (!(alive _unit)) then {hint "player dead"};
if (_unit != vehicle _unit) then {hint "player in vehicle"};
if (_actionOptionsID != -1) then {_actionOptionsObject removeAction _actionOptionsID; _actionOptionsID = -1};
sleep 1;
   };
};
};

sleep 1;
[] spawn LinkCTI_MHQBuildAction;
Title: Re: Very weird error... Please help!
Post by: L!nk on 02 Mar 2008, 12:56:22
aha! seem to work so far.

Just wondering, you sire have a diffirent way of programming than mine.

Is mine incorrect or is it just esier for you.

Why the "isNil" and "spawn" and "private" commands.

Mine still works but, I just want to know I your is maybe better?