Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
LavaRS

Welcome Screen if statement

4 posts in this topic

Okay so I've set my script so that if it logs into an account & the bank pin is set, but there's not a pin in account manager it logs out, however it only OCCASIONALLY works for some reason, sometimes it'll recognize there's a pin from welcome screen, then other times it wont..

 

CODE EXAMPLE

    private void handleWelcomeScreen() {
        scriptStatus = "Handling welcome screen";

        RSInterfaceMaster[] ints = Interfaces.getAll();
        for (RSInterfaceMaster i : ints) {
            RSInterfaceChild[] children = i.getChildren();
            for (RSInterfaceChild c : children) {
                if (!c.getText().isEmpty()) {
                    if (c.getUID() == 24772624 && c.getParentID() == 10813468) {
                        if (c.getText()
                                .contains("You do not have a Bank PIN. Please visit a bank if you would like one.")) {
                            bankPinStatus = false;
                        } else {
                            bankPinStatus = true;
                        }
                    }
                }

            }
        }

 

Also another question, is it possible if bank is opened with pin, to select " Exit " on the dialogue and log out?

Share this post


Link to post
Share on other sites

Why not just have them open the bank and check if the pin screen is open using isPinScreenOpen and if it is then you know they have a pin and if not well they obviously don't.

1 person likes this

Share this post


Link to post
Share on other sites

I think the issue might be that the login bot thread takes precedence over the script thread. In my experience, it seems like the login bot thread ends when the "Click here to play" button is clicked. I'm guessing that sometimes your script begins firing quickly enough to grab those interfaces and check them, and other times it doesn't.

It's a gross solution, but if you have to detect the text at the welcome interface, I'm wondering if the only thing you can do is to spawn a separate thread (this won't be blocked by the login bot thread) to check if that interface text is there. If your script can change a bit, it seems more intelligent to do what Boston said and check for it at the bank screen itself. It's definitely possible to click the exit button on the bank pin interface and then logout from there.

This is unrelated but worth mentioning:

if (c.getText().contains("You do not have a Bank PIN. Please visit a bank if you would like one.")) {
     bankPinStatus = false;
} else {
     bankPinStatus = true;
}

That can (preferably) be written like this:

bankPinStatus = !c.getText().contains("You do not have a Bank PIN."));

When you find yourself assigning a boolean value based on a single condition in an if-else block, it's better to just assign the variable directly to the condition. It's needlessly verbose to write it the way you have. Additionally, String#contains will return true if a string contains the substring you've passed in -- there's no need to match the entire string!

Edited by deus-x

Share this post


Link to post
Share on other sites
public void handleWelcomeScreen() {
	if (Timing.waitCondition(new Condition() {
			@Override
			public boolean active() {
				General.sleep(50);
				return Login.getLoginState() == STATE.WELCOME_SCREEN;
			}
	}, General.random(20000, 30000)) {
		setLoginBotState(false);
		bankPinStatus = checkPin();
		setLoginBotState(true);     // if login bot fails to realise it's on welcome screen, then click on "Click here to play" yourself
	}
}
private boolean checkPin() {
	if (!Interfaces.isValidInterface(378))
		return false;
	final RSInterface pin = Interfaces.get(378, 16);
	return pin != null && "you have a bank pin!".equalsIgnoreCase(pin.getText());
}

 

Edited by Beg
1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.