infinite loop
#1

hey guys,i had a server kicking prob they said its caused by infinite loop how to find an infinaite loop? wat is it?
Reply
#2

anyone?
Reply
#3

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.
Reply
#4

EDIT: whoops, submitted it twice, my bad.
Reply
#5

i got it now,wat is the easiet way to find it in my script ?
Reply
#6

Reading.
Reply
#7

im pretty new to scripting so both shouldnt be 1?
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)