Jump to content
Alert23

Script Help (say3D)

Recommended Posts

Hi all i have this script:

 

[] spawn {while {true} do {  

	{if ((side _x == resistance && _x distance player < 10 && speed player >= 5.5)) then {
	_x say3D "I_Just_Heared_Footsteps"} 
	else {};

		} forEach allUnits;
	};

};

now _x says the say3D unlimited times but i want him to say it only once while the "if" condition is fulfilled.

please help some1.

Edited by Alert23
corrected question

Share this post


Link to post
Share on other sites

Here's a solution that uses the setvariable

 

[] spawn {while {true} do {  

{
if(!(_x getVariable ["alerted",false])) then // If not said yet
{
	if ((side _x == resistance && _x distance player < 10 && speed player >= 5.5)) then 
	{
	_x say3D "I_Just_Heared_Footsteps";
	_x setVariable ["alerted",true]; // Say only once
	} 
	else {};
};

} forEach allUnits;
		
	
 sleep 1; // Sleep is good to have
 
	};
};

Code not tested...

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, gc8 said:

Here's a solution that uses the setvariable

 


[] spawn {while {true} do {  

{
if(!(_x getVariable ["alerted",false])) then // If not said yet
{
	if ((side _x == resistance && _x distance player < 10 && speed player >= 5.5)) then 
	{
	_x say3D "I_Just_Heared_Footsteps";
	_x setVariable ["alerted",true]; // Say only once
	} 
	else {};
};

} forEach allUnits;
		
	
 sleep 1; // Sleep is good to have
 
	};
};

Code not tested...

hey thanks for your help!

this definitly solves the say3D issue i had before but for some reason the enemy does the whole "while" command only once.

i want him to do it every time when the condition is fulfilled:

so basicly every time this condition:

_x distance player < 10 && captive player && speed player >= 5.5

is met do the while loop

[] spawn {while {true} do {  

	{
	if(!(_x getVariable ["alerted",false])) then // If not said yet
	{
		if ((side _x == resistance && _x distance player < 10 && captive player && speed player >= 5.5)) then {
	
			_x say3D "I_Just_Heared_Footsteps";
			_x setVariable ["alerted",true]; // Say only once
			_x forceWalk true;
			_x doMove (position player);
			_x setBehaviour "AWARE";
			_x setCombatMode "RED";
			} 
			else {};
		};

	} forEach allUnits;
	sleep 1; // Sleep is good to have
 	};
};

 

Share this post


Link to post
Share on other sites

Not sure I understand but this would make it say the line once and reset when condition is not met anymore:

 

 

[] spawn {while {true} do {  

	{

		if ((side _x == resistance && _x distance player < 10 && captive player && speed player >= 5.5)) then 
        {
          
		if(!(_x getVariable ["alerted",false])) then // If not said yet
	    {
			_x say3D "I_Just_Heared_Footsteps";
			_x setVariable ["alerted",true]; // Say only once
			_x forceWalk true;
			_x doMove (position player);
			_x setBehaviour "AWARE";
			_x setCombatMode "RED";
         };
          
		 } 
		 else 
         {
          _x setVariable ["alerted",false]; // Reset variable, can use say3D again
         };

	} forEach allUnits;
	sleep 1; // Sleep is good to have
 	};
};

 

Again code not tested

  • Thanks 1

Share this post


Link to post
Share on other sites
18 minutes ago, gc8 said:

Not sure I understand but this would make it say the line once and reset when condition is not met anymore:

 

 


[] spawn {while {true} do {  

	{

		if ((side _x == resistance && _x distance player < 10 && captive player && speed player >= 5.5)) then 
        {
          
		if(!(_x getVariable ["alerted",false])) then // If not said yet
	    {
			_x say3D "I_Just_Heared_Footsteps";
			_x setVariable ["alerted",true]; // Say only once
			_x forceWalk true;
			_x doMove (position player);
			_x setBehaviour "AWARE";
			_x setCombatMode "RED";
         };
          
		 } 
		 else 
         {
          _x setVariable ["alerted",false]; // Reset variable, can use say3D again
         };

	} forEach allUnits;
	sleep 1; // Sleep is good to have
 	};
};

 

Again code not tested

Thx this works!

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

×