Jump to content
MechSlayer

Code won't continue after while loop

Recommended Posts

I have this code 

GSO_fnc_necesidades =
{
	while {true} do
	{
		_sed = player getVariable "sed";
		_sed = _sed - 1;
		player setVariable ["sed", _sed, true];
		Sed = _sed;
		sleep 5;
	};
		
	while {true} do
	{
		_hambre = player getVariable "hambre";
		_hambre = _hambre - 1;
		player setVariable ["hambre", _hambre, true];
		Hambre = _hambre;
		sleep 10;
	};
};

And I call it with [] spawn GSO_fnc_necesidades;

The problem is that it runs only the first while loop, any fix?

Share this post


Link to post
Share on other sites
28 minutes ago, MechSlayer said:

The problem is that

 

Hello there MechSlayer !

 

You cant add two loops like this and why to do this actually  ?

add them in one code.

Share this post


Link to post
Share on other sites

Hmm strange, I made it work like this before. I need to run them separate because one must go slower than the other

Share this post


Link to post
Share on other sites
1 minute ago, MechSlayer said:

run them separate

 

Should be the best option.

Share this post


Link to post
Share on other sites

else you can do this :

 

GSO_fnc_necesidades =
{

	[]spawn{
		while {true} do
		{
			systemchat "1";
			sleep 5;
		};
	};
		
	[]spawn{
		while {true} do
		{
			systemchat "2";
			sleep 3;
		};
	};
};


call GSO_fnc_necesidades;

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
7 minutes ago, GEORGE FLOROS GR said:

else you can do this :

 


GSO_fnc_necesidades =
{

	[]spawn{
		while {true} do
		{
			systemchat "1";
			sleep 5;
		};
	};
		
	[]spawn{
		while {true} do
		{
			systemchat "2";
			sleep 3;
		};
	};
};


call GSO_fnc_necesidades;

 

Now it won't continue after the "call GSO_fnc_necesidades;

GSO_fnc_InitCliente =
{
	cutText ["","BLACK OUT"];
	waituntil {!(IsNull (findDisplay 46))};


	cutText [format ["Recuperando datos de %1", name player],"BLACK OUT"];
	[player] remoteExecCall ["Servidor_fnc_crearJugador", 2];
	sleep 6;
	
	[] spawn GSO_fnc_configuraciones;
	[] spawn GSO_fnc_necesidades;
	1 cutRsc ["HUD","PLAIN",-1,false];
	call GSO_fnc_hud;

	(findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 219) then {[] spawn GSO_fnc_abrirMenu;};"];
	cutText ["", "PLAIN"];
	["Datos cargados", "info", 5] spawn GSO_fnc_notificaciones;
};

 

Share this post


Link to post
Share on other sites
10 hours ago, MechSlayer said:

Now it won't continue after the "call GSO_fnc_necesidades;

If both loops are spawned there is no reason for it not to continue, you must be doing something else you are not showing 

  • Like 1

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

×