Infinite loop...
#1

Hello, so I'm having some trouble trying to fix this, and finally I have ran out of ideas.

So I got this loop:

PHP код:
new random = INVALID_PLAYER_ID;
    do{
        
random = Iter_Random(Player);// I use foreach include (pick a random player).
    
}while(!IsLoggedIn[random] || IsJailed[random] == 1 || IsAFK[random] == 1); 
I have checks, so if people disconnect and players reach 0, it won't start, the problem comes when someone disconnects while the loop is running, and Player counter reaches 0, then the loop will go forever and freeze the server. I have tried this:

PHP код:
new random = INVALID_PLAYER_ID, counter = 0;
    do{
        
random = Iter_Random(Player);
    
counter++;
    }while(!
IsLoggedIn[random] || IsJailed[random] == 1 || IsAFK[random] == 1 || counter < 30);//to try and stop it, but still freezes the server. 
I have tried checking player counter while in the loop, but nothing.

Any ideas? Thank you.
Reply


Messages In This Thread
Infinite loop... - by insus100 - 01.05.2018, 00:27
Re: Infinite loop... - by CodeStyle175 - 01.05.2018, 00:35
Re: Infinite loop... - by JesterlJoker - 01.05.2018, 00:38
Re: Infinite loop... - by insus100 - 01.05.2018, 00:41
Re: Infinite loop... - by CodeStyle175 - 01.05.2018, 00:47
Re: Infinite loop... - by insus100 - 01.05.2018, 00:54
Re: Infinite loop... - by Dayrion - 01.05.2018, 01:57
Re: Infinite loop... - by jlalt - 01.05.2018, 02:04

Forum Jump:


Users browsing this thread: 1 Guest(s)