2 for(;;) loops

Posts 1–6 of 6 · Page 1 of 1
2 for(;;) loops
Hey all.

I was just do some coding, and I'm almost finished with it.
But I got a problem with 2 for(; loops :

Code:
Somethread()
{
	if(something)
        {
		waittillspawn();
		waittillprematch();
	}
}

waittillprematch()
{
	for(;;)
	{
			level waittill("prematch_over");
			DoSomething();
	}
}
waittillspawn()
{
	for(;;)
	{
		foreach(player in level.players)
		{
			player waittill("spawned_player");
			DoSomething();
		}
	}
}
I know both codes works perfectly, but they seem not to work at the same time ...?
Can someone help me with this ^^.

PS: Somebody knows a code that wait for 2 things at the ssame time like waittill( "player_spawned" || "player_connected" );?
your not calling the threads right
Code:
Somethread()
{
	if(something)
        {
		[level, player or self] thread waittillspawn();
		[level, player or self] thread waittillprematch();
	}
}
PS: Somebody knows a code that wait for 2 things at the ssame time like waittill( "player_spawned" || "player_connected" );?
waittill_any("player_spawned", "player_connected");

and for the last loop, there will be alot of lag unless if you add a wait
Code:
self waittill_any("death", "disconnect");
Code:
Somethread()
{
	if(something)
        {
		self thread waittillspawn();
                wait 0.6; //doesn't really matter of a ms, it's still less than a sec, so it's fast
		self thread waittillprematch();
	}
}
prematch won't work if calling it onPlayerSpawned, call it on init as
Code:
level thread
Code:
waittillspawn()
{
level waittill("prematch_over");
self thread DoSomething();
}
Quote Originally Posted by [WhA]4FunPlayin View Post
prematch won't work if calling it onPlayerSpawned, call it on init as
last time i tested something like this it didn't matter, although i still could be wrong
Well yea, it does work, but it's pretty pointless to make a timer for checking if game ends every time that someone spawns.

Or isHost but meh whatever.
If you dont add "thread" to a called function it will wait for return to continue.
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us