OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started 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.
-
Post the whole loop, the problem is inside it most likely.
-
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)
-
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
-
Still have to figured this out. Someone please help. This is preventing me from doing something awesome.
Thx.
L!nk
-
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
-
while {(alive player) && (player == vehicle player) && ((player distance WestMHQ) < 50)} do
{
sleep 1;
};
-
here is the whole file.
called in this way: [] execVM "filename.sqf"
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;
-
Try this and read the NOTE:
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;
-
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?