do while loop not working
#1

Hello everybody! So Im using this loop:
PHP код:
new sorte;//This is the random player we are choosing.
//now the loop:
do
{
        
sorte Iter_Random(Player);//I use foreach.
}
while(!
Logado[sorte] || pInfo[sorte][pIdade] == 1);
//While he isnt logged OR he is Jailed (Using pIdade for Jailed, yeah) Repeat the loop.
fInfo[sorte][fBandit] = 1;//Here I set the faction to spawn
foreach(Playeri)
if(
!= sorte || pInfo[i][pIdade] == || pInfo[i][pAviso] > 0)// If player isnt bandit and he isnt jailed.
{
    
fInfo[i][fPolice] = 1//Then, he is a cop.
}
 
So The problem is that if you are jailedyou still spawn to the game (being a cop) and it's so annoying damn. 
I have tried using a simple:
PHP код:
while(!Logado[sorte] || pInfo[sorte][pIdade] == || pInfo[sorte][pAviso] > 0//If he isnt logged in OR he is jailed.
    
{
             
sorte Iter_Random(Player); //Pick random player(foreach)
    

Doesnt work, I have used if too. Thanks for your help guys..
Reply
#2

I think the problem here is with your second loop logic. Replace all of the ORs to ANDs and modify the check a bit because you need for all of the checks to pass to succesfully declare a cop. Now I think pAviso (whatever that is) > 0 might be true for the bandits so they all become cops.

Change

PHP код:
foreach(Playeri
if(
!= sorte || pInfo[i][pIdade] == || pInfo[i][pAviso] > 0)// If player isnt bandit and he isnt jailed. 

    
fInfo[i][fPolice] = 1//Then, he is a cop. 

To

PHP код:
foreach(Playeri
if(
!= sorte && pInfo[i][pIdade] != && pInfo[i][pAviso] > 0)// If player isnt bandit and he isnt jailed. 

    
fInfo[i][fPolice] = 1//Then, he is a cop. 

Reply
#3

I thought about that, I will try it. pAviso is jail time, so it would act the same as pIdade (pJailed) so I Will remove it. Ill change the Ors for ands
Reply
#4

Fixed..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)