infinite loop -
ProShooter22 - 24.04.2013
hey guys,i had a server kicking prob they said its caused by infinite loop how to find an infinaite loop? wat is it?
Re: infinite loop -
ProShooter22 - 24.04.2013
anyone?
Re: infinite loop -
Sithis - 24.04.2013
An infinite loop is when a piece of code runs continuously, without ending. This causes your script to freeze, because it will continuously loop though that piece of code.
Example:
pawn Код:
new somevar = 1;
while(somevar == 1)
{
DoSomeFunction();
}
This code will run forever since somevar will never change to something other than 1.
Re: infinite loop -
Sithis - 24.04.2013
EDIT: whoops, submitted it twice, my bad.
Re: infinite loop -
ProShooter22 - 25.04.2013
i got it now,wat is the easiet way to find it in my script ?
Re: infinite loop -
Scenario - 25.04.2013
Reading.
Re: infinite loop -
ProShooter22 - 25.04.2013
im pretty new to scripting so both shouldnt be 1?
Re: infinite loop -
YesYesYes - 25.04.2013
just check all loops , search for "while" in your script
now if you find anything like this-
pawn Код:
new v=6;
while( v > 5 )
{
v++;
}
now, read my text carefully, and try to understand what I'm saying..
this loop is increasing values... the "while" says that the loop will continue to run if variable "v" is greater than 5.
and you can see this loop is increasing the value of 5, so everytime it will increase the value, and everytime it will be greater than 5, so this loop will never end as the value will always be greater than 5, in this case, we need to check values, a correct, ending loop is like this one (listen, loop varies, they are not always the same, we make it according to our use;
pawn Код:
new v = 1;
while( v < 10 )
{
v++;
}
now this loop, what it does is, there is a variable with value = 1, now the "while" checks if the value is LESS than 10, and if the value is less(as it is) the loop will run, and increase the value of variable "v" , and when V will reach 10, the condition which is that V is less than 10, will be false, as v will be 10, so this loop will stop, I hope you will understand something, I wrote this all for you