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
seany123456

Login method

14 posts in this topic

Hello, I want to create my own code for logging in, so i tried looking at the api to see how the login() is done but i cant see the code?

is it possible to see the code used for logging in?, if so where can i find it?

if not could anyone give me the basics on what is used to perform the login?,  so i can then look into it further.

thanks.

 

Share this post


Link to post
Share on other sites

API implementation code is not available to public. 

It's most likely a thread that is active when login screen is detected. To handle it, maybe interfaces, keyboard and mouse.

Share this post


Link to post
Share on other sites
3 hours ago, seany123456 said:

Hello, I want to create my own code for logging in, so i tried looking at the api to see how the login() is done but i cant see the code?

is it possible to see the code used for logging in?, if so where can i find it?

if not could anyone give me the basics on what is used to perform the login?,  so i can then look into it further.

thanks.

 

Use Login.getLoginResponse() to determine "state", color for world select screen, interfaces for click here to continue, and mouse positions for the actually logging in. If you hit cancel and Existing User again it resets the login response and the content that was typed in. It will require some playing around with :)

 

I'm sure there are other ways to do it too! 

Edited by FALSkills

Share this post


Link to post
Share on other sites
7 hours ago, FALSkills said:

Use Login.getLoginResponse() to determine "state", color for world select screen, interfaces for click here to continue, and mouse positions for the actually logging in. If you hit cancel and Existing User again it resets the login response and the content that was typed in. It will require some playing around with :)

 

I'm sure there are other ways to do it too! 

thanks for the response, i'm quite new to scripting so i think i'm taking on more than i can chew at this moment in time, but ill definitly be testing this out and see if i can get something working to a reasonable standard.

thanks

Share this post


Link to post
Share on other sites

Check the settings that change upon logging in and out. Fill in the interfaces accordingly and login afterwards. It can be hard to do if you're new to scripting but otherwise it's an easy process. 

Share this post


Link to post
Share on other sites

Ok, so I have been fiddling around with a custom login, The end purpose of doing this is so i can use more than 1 account with the same script, for this reason I'm not interested in using 100% custom code unless its needed, that's why I've used Login.login() rather than doing it all myself.

This is working but its obviously very rough and probably wouldn't work for long if it was in a live script.

issues I'm currently having are;

first: because i'm using Login.login(), i'm not able to use getLoginResponse, so the script is not going to know if there was an error logging into account 1, so i might need a fail safe or counter in there, maybe just a i++ could do the job? any suggestions?

second: during the Login.login, the Login.STATE seems to change to INGAME before the welcomescreen is even loaded, this is causing the script to jump over the if statement for welcomescreen, I have added a sleep(1000,15000) which works as a quick fix but i dont really want the script to wait 10-15 seconds before continuing if it doesn't need to. any suggestions on ways around this?

third: as i mentioned above the reason for doing this was so i could use multiple accounts within the same script, as this is a private script im happy to have the account details in the script itself, I'm not sure how to do that?

 

any help on these matters would be greatly appreciated.

Thanks.

 

	public void customLogin(){
		if(Login.getLoginState().equals(Login.STATE.LOGINSCREEN)){
			println ("LoginScreen Found, so Logging in.");
			Login.login("USERNAME", "PASSWORD");
			sleep(10000,15000);
		}
		if(Login.getLoginState().equals(Login.STATE.WELCOMESCREEN)){
			println ("We're at the welcome screen, Clicking the welcome screen");
			final RSInterface welcomescreen = Interfaces.get(378, 6);
			Clicking.click(welcomescreen);
		}
		if(Login.getLoginState().equals(Login.STATE.INGAME)){
			println("We're Logged in, now time to get working.");
			sleep(30000,60000);
		}
	}

 

 

Share this post


Link to post
Share on other sites

extending on my previous post, I've been trying to work on how to handle the accounts this is what i have so far:

please let me know if you can see any issues with it now or any issues i may come across in future doing it this way.

 

	String account_username = null;
	String account_password = null;
	int account = 1;
	
	//switch for different accounts.
	public void account_switch(){
		switch (account){
		case 1:
			account_username = "account1";
			account_password = "";
			break;
		case 2:
			account_username = "account2";
			account_password = "";	
			break;
		case 3:
			account_username = "account3";
			account_password = "";
			break;
		}
	}

 

thanks

Sean

Share this post


Link to post
Share on other sites

I'm also new to scripting but have a few suggestions.

This is what i use in my muling script to login (could probably be inproved): 

				do {
					Login.login();
				} while (Game.getGameState() != 30);
				
				if (Interfaces.isInterfaceValid(378)){
					Interfaces.get(378, 17).click();
				}

The interface is the red "click to continue" button. 

 

The sleep in your customlogin could be replaced with a conditional sleep. This explains it pretty well.

 

1 person likes this

Share this post


Link to post
Share on other sites
18 minutes ago, botuser420 said:

I'm also new to scripting but have a few suggestions.

This is what i use in my muling script to login (could probably be inproved): 


				do {
					Login.login();
				} while (Game.getGameState() != 30);
				
				if (Interfaces.isInterfaceValid(378)){
					Interfaces.get(378, 17).click();
				}

The interface is the red "click to continue" button. 

 

The sleep in your customlogin could be replaced with a conditional sleep. This explains it pretty well.

 

Thanks for the reply, yes that looks to work much more smoothly thank you, ill check out the conditional sleep, however i can probably do without sleep now.

although interface 378 child 17 is only the right part of the red button, whereas child 6 is the entire red button, so I'm assuming its best to use child 6?

 

Thanks

sean

Share this post


Link to post
Share on other sites
On 15/05/2016 at 8:49 PM, seany123456 said:

although interface 378 child 17 is only the right part of the red button, whereas child 6 is the entire red button, so I'm assuming its best to use child 6?

Yes, use child 6.

Share this post


Link to post
Share on other sites
18 minutes ago, Beg said:

Yes, use child 6.

yes i have done that and it works well, should i implement some sort of fail safe after Login#login, if the script is still not logged in?

thinking i could use some kind of i++ in the do loop and if it reaches x then to have it switch account.

 

also i have been working on the account switching/selecting code, the idea of what i'm trying to achieve is the script runs through 5 accounts,  after completing account 5, its to start again at account1 and keep going, what I've done i know is fairly raw but does it look like the best way of accomplishing my goal?

feels a little counter productive to have all those if statements into the switch

 

full code below

 

package scripts;

import org.tribot.api2007.Game;
import org.tribot.api2007.Interfaces;
import org.tribot.api2007.Login;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

@ScriptManifest(authors = { "Seany" }, category = "Tools", name = "Xtreme")
public class Xtreme extends Script {
	
	String account_username;
	String account_password;
	
	//Default 1 as when starting script will always start on first account.
	int account = 1;
	
	//Default False as will assume none of the account have complete any runs.
	boolean account1Complete = false;
	boolean account2Complete = false;
	boolean account3Complete = false;
	boolean account4Complete = false;
	boolean account5Complete = false;
	
	private boolean onStart(){
		println("Xtreme has started.");
		println("Version 0.3");
		setLoginBotState(false);
		return true;
	}
	
	//This code takes current account and checks with accountComplete to see if account has complete a turn.
	//This code is used in accountSwitcher to confirm which account to switch to.
	public void accountSelector(){
		switch(account) {
			case 1:
			if ((account1Complete) && (account5Complete)){
				account1Complete = false;
				account2Complete = false;
				account3Complete = false;
				account4Complete = false;
				account5Complete = false;
				account = 1;
				break;
			} else if ((account1Complete) && (!account2Complete)){
				account = 2;
				break;
			} else if(!account1Complete){
				account = 1;
				break;
			} else {
				throw new RuntimeException("ERROR WITH ACCOUNT MANAGEMENT - E0001");
			}
			case 2:
			if(account2Complete){
				account = 3;
				break;
			}
			case 3:
			if(account3Complete){
				account = 4;
				break;
			}
			case 4:
			if(account4Complete){
				account = 5;
				break;
			}
			case 5:
			if(account5Complete){
				account = 1;
				break;
			}
		}
	}
	
	//This code switches which account is active, using code from accountSelector.
	//The switch assigns account_username and account_password. - these will need to be manually added.
	public void accountSwitcher(){
		accountSelector();
		switch(account){
			case 1:
				account_username = "account1";
				account_password = "pass";
				break;
			case 2:
				account_username = "account2";
				account_password = "pass";
				break;
			case 3:
				account_username = "account3";
				account_password = "pass";
				break;
			case 4:
				account_username = "account4";
				account_password = "pass";
				break;
			case 5:
				account_username = "account5";
				account_password = "pass";
				break;
			}
	}

	//im thinking i might need to add failsafes within the do loop,
	//if the do loop runs 3 times without login success then find way to skip current account.
	public void customLogin(){
		do {
			//println ("LoginScreen Found, so Logging in.");
			Login.login(account_username, account_password);
		} while (Game.getGameState() != 30);
		
		if (Interfaces.isInterfaceValid(378)){
			println ("We're at the welcome screen, Clicking the welcome screen");
			Interfaces.get(378, 6).click();
		}
		
		if (Game.getGameState() == 30){
			println("We're Logged in, now time to get working.");
		}
	}
	
	@Override
	public void run(){
		if(onStart()){
			while(true){
				sleep(loop());
				//Login
				accountSwitcher();
				customLogin();
			}
		}
	}
	
	private int loop() {
		return 42;
	}
}

any help/guidance would be appreciated.

sean

Share this post


Link to post
Share on other sites

A class for an Account which would contain account's information.
You could use some sort of circular queue to iterate through them.

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.