Thread: 2 for(;;) loops

Results 1 to 6 of 6
  1. #1
    maarten551's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    255
    Reputation
    10
    Thanks
    75
    My Mood
    Mellow

    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" );?

    My Youtube account : Maarten551, subscribe me ^^
    [YOUTUBE]lSl0HlhGQsY[/YOUTUBE]
    AIzombies for Alteriw, Check it now!
    [YOUTUBE]U9OjBsHgcKQ[/YOUTUBE]
    hover/cordinates mod with visible bunkers!!!
    ---------------------------------------------------
    Most important waittills

  2. #2
    bomb21's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Unknown
    Posts
    57
    Reputation
    10
    Thanks
    22
    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

  3. #3
    [WhA]4FunPlayin's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Location
    Not here
    Posts
    757
    Reputation
    8
    Thanks
    169
    My Mood
    Lonely
    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();
    }

  4. #4
    bomb21's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Unknown
    Posts
    57
    Reputation
    10
    Thanks
    22
    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

  5. #5
    [WhA]4FunPlayin's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Location
    Not here
    Posts
    757
    Reputation
    8
    Thanks
    169
    My Mood
    Lonely
    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.

  6. #6
    zxz0O0's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    209
    Reputation
    10
    Thanks
    136
    My Mood
    Aggressive
    If you dont add "thread" to a called function it will wait for return to continue.
    [YOUTUBE]Ja7-WnJcMcs[/YOUTUBE]

Similar Threads

  1. [HELP]"for" loop
    By Drake in forum C++/C Programming
    Replies: 4
    Last Post: 02-20-2011, 06:26 AM
  2. Hacks for mmorpg?
    By suppaman in forum General Game Hacking
    Replies: 6
    Last Post: 10-17-2010, 12:04 PM
  3. [Source]FOR Loops
    By HypnoticBabeTrap in forum C++/C Programming
    Replies: 13
    Last Post: 12-27-2009, 07:20 PM
  4. A for() loop in a for() loop
    By BooYa in forum C++/C Programming
    Replies: 9
    Last Post: 10-14-2009, 01:41 PM
  5. Too Ownage For Words.
    By Flawless in forum Art & Graphic Design
    Replies: 8
    Last Post: 12-28-2005, 05:55 PM