SRL Archive - Java Help and Tutorials

Need help


syberium

2008-12-01 18:47:33

Hey, I'm learning java but i cant understand why this failsafe does not work.
public boolean login() {
if (isLoggedIn()) {
return true;
}
if (!isLoginScreen()) {
return false;
}
for (int i = 0; i < 5; i++) {


if (getLoginIndex() == 10) {

//clickMouse(300, 165, 146, 14, true);
input.sendKeys("", true);
wait(random(50, 200));
Account account = getAccount();
input.sendKeys(account.getUsername(), true);
wait(random(100, 400));
input.sendKeys(account.getPassword(), true);
//clickMouse(300, 360, 146, 14, true);


}
if (getLoginIndex() == 30) {
break;
}
wait(random(500, 1000));
}
return getLoginIndex() == 30;
}


now i'm guessing the for (int = 0; i < 5; i++) means that it loops while i < 5? and the i++ means increment I by one each time it loops? so it should once it has done this loop 5 times correct? The problem is this loop repeats thousands of times, and I have no idea why. Any help would appreciated.
Thanks.

-Syberium

Method

2008-12-01 18:56:12

I'd suggest asking on the RSBot forums (assuming this is using RSBot code). I really doubt that the problem is the for loop. Try debugging where it goes each time (and try using System.out.print to show what i is) to find out the real source of the problem.

senrath

2008-12-01 18:58:23

The only thing I can think if is that perhaps the login() command is being repeatedly called by the program. The for loop is perfectly valid, and should only run 5 times.

Bobarkinator

2008-12-05 08:11:00

Could also be a problem with one of the other methods looping.

jhildy

2008-12-13 23:15:47

I know i'm not really helping your problem but why is this like this
if (isLoggedIn()) {
return true;
}
if (!isLoginScreen()) {
return false;
}

if loggedin and !isloginscreen both mean it will be ingame and it returns true and exits it could never technically return false there since it would exit before it got to that return statement.