Jump to content
Duffman_DK

While loop with 2 if conditions not working

Recommended Posts

Cannot seem to get this while loop to repeat the code with these 2 if conditions.
It stops after the first sleep, and does not loop to check the if conditions.
What am I missing?

 

phoneringing = false;
phonehascalled = 0;
addactionphone = false;
phonepickedup = false;



while { phoneringing } do
		
		{

			Playsound ["Orange_PhoneCall_Ringtone", true];
			phonehascalled = phonehascalled +1;
			
			sleep 1;

		
				if (Player2 inArea homedesk) && (!addactionphone) then 
				{	
			
						[deskphonehome, ["Tag telefonen", { phoneringing = false;
						phonepickedup = true;
						["pickupphone","SUCCEEDED"] call BIS_fnc_taskSetState;
						(_this select 0) removeaction (_this select 2)}]]remoteExec ["addAction"];				
						addactionphone = true;
			
			
				}		
			
				else {
				
			sleep 1;
			
				if (phonehascalled > 30) then 
				{
						phoneringing = false;
						[
							["I nåede ikke at tage telefonen"],safeZoneX, safeZoneH / 2,true,"<t font='PuristaBold'>%1</t>",[],{ false },true
						] spawn BIS_fnc_typeText2;
						["pickupphone","FAILED"] call BIS_fnc_taskSetState;
						["endm3", false, 10] call BIS_fnc_endMission;
				}
			
				else {};
			
			
				};	
		};					
		
		
	
		waituntil {phonepickedup};

 

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/Debugging_Techniques - and look for showScriptErrors, you may want to turn that on.

But, how is your first while loop even running?

phoneringing = false;

while { phoneringing } do

 

For the two conditions:
 

//WRONG
if (Player2 inArea homedesk) && (!addactionphone) then

//RIGHT
if ((Player2 inArea homedesk) && (!addactionphone)) then

 

  • Like 1

Share this post


Link to post
Share on other sites

beno83_au thx a lot for the link to the debugging , will definitely check that out.

 

18 hours ago, beno_83au said:

https://community.bistudio.com/wiki/Debugging_Techniques - and look for showScriptErrors, you may want to turn that on.

But, how is your first while loop even running?


phoneringing = false;

while { phoneringing } do

 

Ahh yes sorry, forgot the include the first part of the code that sets the phoneringing variable to true ..

 

 

18 hours ago, beno_83au said:

 


//WRONG
if (Player2 inArea homedesk) && (!addactionphone) then

//RIGHT
if ((Player2 inArea homedesk) && (!addactionphone)) then

 

Great, thx a lot, will test it when I get a chance :)

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

×