Jump to content

Recommended Posts

Hi,

 

I am just getting started in scripting. I have a basic script that makes a unit walk a certain distance. Then i wanted him to salute while another player is alive "t1". 

 

But it seems even when i kill "t1". He keeps saluting. Should the while loop not automatically finish when the condition "while {alive t1}" isn't met?

I got around this by adding an exit condition, but this doesn't seem right as it defeats the purpose of a while loop. 

 

Thank you for any help. 

//S1 Move and salute
for "_i" from 0 to 3 do
	{
		s1 playmove "AmovPercMwlkSlowWrflDf_ver2";
	};

while {alive t1} do
	{
		hint "He's Alive";
		s1 playmove "AmovPercMstpSnonWnonDnon_SaluteIn";
		sleep 0.769;
		if (!alive t1) exitwith {};
	};
if (!alive t1) then {hint "He's Dead"};

 

Share this post


Link to post
Share on other sites
14 minutes ago, micklivi1 said:

Should the while loop not automatically finish when the condition "while {alive t1}" isn't met?

It should.

Did I get this right? The dead unit is still saluting despite being dead?

Share this post


Link to post
Share on other sites
2 minutes ago, Dedmen said:

It should.

Did I get this right? The dead unit is still saluting despite being dead?

The soldier S1 is saluting. When t1 dies, S1 is still saluting.

Share this post


Link to post
Share on other sites
3 minutes ago, killzone_kid said:

playMove is added in a queue, so while salutes exist in the queue it will salute regardless if other unit is dead

I see so even if i use a while command. I will need to write an exit condition?

Share this post


Link to post
Share on other sites
3 minutes ago, micklivi1 said:

I see so even if i use a while command. I will need to write an exit condition?

“The difference between playMove and playMoveNow is that playMove adds another move to the move queue, while playMoveNow replaces the whole move queue with new move:”

  • Like 1

Share this post


Link to post
Share on other sites

Ahh, it's playmovenow. Works perfect now! Thanks for the help!

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

×