#1

HI,

Why when cikle is with while(

If while is very long, server is no working anymore? server is on, but no response.
Reply
#2

Basically it works the same as the Loo, showing us your CODE would help.

pawn Код:
//Easier but rarely used or mostly used by experienced scripters
new
    i = 0;

while(i < MAX_PLAYERS)
{
    //do stuff here
    i++;
}

// Mostly used by beginners, the code looks long, but it's mostly used by people
for(new i = 0; i < MAX_PLAYERS; i++)
{
    // Do stuff here
}

//loops means increasing the variable by 1 until it reaches the maximum value.
Reply
#3

I believe that you do not increase the value is used in while and it's an infinite loop; hence it makes the server to stop.

I'd recommend you to use for loop but in case you want to use while, it can also be done like:
pawn Код:
new
    i = -1;

// increasing i by 1 and it returns the new value - it basically starts as: while(0 < MAX_PLAYERS) and it is increased later on..
while (++i < MAX_PLAYERS)
{
    //do stuff here
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)