while - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: while (
/showthread.php?tid=482553)
while -
audriuxxx - 21.12.2013
HI,
Why when cikle is with while(
If while is very long, server is no working anymore? server is on, but no response.
Re: while - Patrick - 21.12.2013
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.
Re: while -
Konstantinos - 21.12.2013
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
}