Jump to content
Sign in to follow this  
Eclipse4349

while {true} do loop help please!

Recommended Posts

I have the following code in a script:

_target1status = 0;

_target2status = 0;

while {true} do

{

sleep 5;

if ((!alive target1) and (_target1status = 0)) then {

hint "Objective Alpha has\nbeen destroyed!";

deletemarkerlocal _alpha;

_target1status = 1};

if ((!alive target2) and (_target2status = 0)) then {

hint "Objective Bravo has\nbeen destroyed!";

deletemarkerlocal _bravo;

_target2status = 1};

if ((!alive target1) and (!alive target 2)) then {

hint "All targets have been destroyed! Mission Completed!";

sleep 8;

endmission "end1"};

_missiontime = 0;

_missiontime = _missiontime + 1;

if (_missiontime >= 360) then {

hint "The mission is a\nfailure. US forces\nmust pull out!";

sleep 8;

endmission "end1"};

};

This is part of a larger script. The rest of the script runs up to this point. I have verified this with inserting:

hint "script running";

at various points.

No matter what I do, I CANNOT get the while loop to execute. What am I missing?

Thanks! I have spent HOURS trying to get this to work! :mad:

Edited by Eclipse4349

Share this post


Link to post
Share on other sites

Hi...do you have -showScriptErrors added to your games shortcut?

...and what does it say in the RPT file? Both of these will help you bigtime.

I suggest the next time you post code to use the code tags...your post is very difficult to read and a lot of people might ignore it because of that!

Share this post


Link to post
Share on other sites

Didn't have time to look at your code much, but check your operators:

if ((!alive target1) and (_target1status = 0)) then {

This is probably what you mean

if ((!alive target1) and (_target1status == 0)) then {

= is assigning

== is comparing

Share this post


Link to post
Share on other sites
Hi...do you have -showScriptErrors added to your games shortcut?

...and what does it say in the RPT file? Both of these will help you bigtime.

I suggest the next time you post code to use the code tags...your post is very difficult to read and a lot of people might ignore it because of that!

There are code tags? Lol... Thanks for the tips, especially the show_script_errors parameter!

Didn't have time to look at your code much, but check your operators:

This is probably what you mean

= is assigning

== is comparing

Thats probably it, THANK YOU!!!

That would explain why I got a while-do loop to work with an alternating hint/sleep/hint/sleep; but as soon as I put and if-then statement in, it wouldn't execute.

I will check it when I get home from work!

Edited by Eclipse4349

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×