Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class myLogBot {
- private int INTERFACE_MAIN = 905,INTERFACE_MAIN_CHILD = 59,INTERFACE_MAIN_CHILD_COMPONENT_ID = 4,INTERFACE_LOGIN_SCREEN = 596
- ,INTERFACE_USERNAME = 59,INTERFACE_USERNAME_WINDOW = 55,INTERFACE_PASSWORD = 73,INTERFACE_PASSWORD_WINDOW = 62
- ,INTERFACE_BUTTON_LOGIN = 63,INTERFACE_TEXT_RETURN = 15,INTERFACE_WELCOME_SCREEN = 906,INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_1 = 178,
- INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_2 = 180,INTERFACE_WELCOME_SCREEN_TEXT_RETURN = 36;
- private int INDEX_LOGGED_OUT = 3,INDEX_LOBBY = 7, invalidCount, worldFullCount;
- private void login(String Username,String Pass) {
- while (game.getClientState() == 3 || game.getClientState() == 7) {
- manualLog(Username,Pass);
- sleep(random(500,1000));
- }
- }
- private int manualLog(String Username,String Pass) {
- String username = Username.replaceAll("_", " ").toLowerCase().trim();
- String returnText = interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_TEXT_RETURN).getText().toLowerCase();
- int textlength;
- if (game.getClientState() != INDEX_LOGGED_OUT) {
- if (!game.isWelcomeScreen()) {
- sleep(random(1000, 2000));
- }
- if (game.getClientState() == INDEX_LOBBY) {
- RSInterface welcome_screen = interfaces.get(INTERFACE_WELCOME_SCREEN);
- RSComponent welcome_screen_button_play_1 = welcome_screen.getComponent(INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_1);
- RSComponent welcome_screen_button_play_2 = welcome_screen.getComponent(INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_2);
- mouse.click(
- welcome_screen_button_play_1.getAbsoluteX(),
- welcome_screen_button_play_1.getAbsoluteY(),
- welcome_screen_button_play_2.getAbsoluteX() + welcome_screen_button_play_2.getWidth() - welcome_screen_button_play_1.getAbsoluteX(),
- welcome_screen_button_play_1.getHeight(),
- true
- );
- for (int i = 0; i < 4 && game.getClientState() == 6; i++) {
- sleep(500);
- }
- returnText = interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(INTERFACE_WELCOME_SCREEN_TEXT_RETURN).getText().toLowerCase();
- if (returnText.contains("members")) {
- log("Unable to login to a members world. Stopping script.");
- RSComponent back_button1 = interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(38);
- RSComponent back_button2 = interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(41);
- mouse.click(back_button1.getAbsoluteX(),back_button1.getAbsoluteY(),
- back_button2.getAbsoluteX() + back_button2.getWidth() - back_button1.getAbsoluteX(),
- back_button1.getHeight(),true);
- interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(203).doClick();
- stopScript(false);
- }
- }
- return -1;
- }
- if (!game.isLoggedIn()) {
- if (returnText.contains("update")) {
- log("Runescape has been updated, please reload RSBot.");
- stopScript(false);
- }
- if (returnText.contains("disable")) {
- log("Your account is banned/disabled.");
- stopScript(false);
- }
- if (returnText.contains("incorrect")) {
- log("Failed to login five times in a row. Stopping script.");
- stopScript(false);
- }
- if (returnText.contains("invalid")) {
- if (invalidCount > 6) {
- log("Unable to login after 6 attempts. Stopping script.");
- log("Please verify that your RSBot account profile is correct.");
- stopScript(false);
- }
- interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(25).doClick();
- invalidCount++;
- return (random(500, 2000));
- }
- if (returnText.contains("full")) {
- if (worldFullCount > 30) {
- log("World Is Full. Waiting for 15 seconds.");
- sleep(random(10000, 15000));
- worldFullCount = 0;
- }
- sleep(random(1000, 1200));
- worldFullCount++;
- }
- if (returnText.contains("world")) {
- return random(1000, 1200);
- }
- if (returnText.contains("performing login")) {
- return random(1000, 1200);
- }
- }
- if (game.getClientState() == INDEX_LOGGED_OUT) {
- if (!atLoginScreen()) {
- interfaces.getComponent(INTERFACE_MAIN, INTERFACE_MAIN_CHILD).getComponent(INTERFACE_MAIN_CHILD_COMPONENT_ID).doAction("");
- return random(500, 600);
- }
- if (isUsernameFilled(Username) && isPasswordFilled(Pass)) {
- interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_BUTTON_LOGIN).doClick();
- return random(500, 600);
- }
- if (!isUsernameFilled(Username)) {
- atLoginInterface(interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_USERNAME_WINDOW));
- sleep(random(500, 700));
- textlength = interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_USERNAME).getText().length() + random(3, 5);
- for (int i = 0; i <= textlength + random(1, 5); i++) {
- keyboard.sendText("\b", false);
- if (random(0, 2) == 1) {
- sleep(random(25, 100));
- }
- }
- keyboard.sendText(username, false);
- return random(500, 600);
- }
- if (isUsernameFilled(Username) && !isPasswordFilled(Pass)) {
- atLoginInterface(interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD_WINDOW));
- sleep(random(500, 700));
- textlength = interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD).getText().length() + random(3, 5);
- for (int i = 0; i <= textlength + random(1, 5); i++) {
- keyboard.sendText("\b", false);
- if (random(0, 2) == 1) {
- sleep(random(25, 100));
- }
- }
- keyboard.sendText(Pass, false);
- }
- }
- return random(500, 2000);
- }
- private boolean atLoginInterface(RSComponent i) {
- if (!i.isValid())
- return false;
- Rectangle pos = i.getArea();
- if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1)
- return false;
- int dy = (int) (pos.getHeight() - 4) / 2;
- int maxRandomX = (int) (pos.getMaxX() - pos.getCenterX());
- int midx = (int) (pos.getCenterX());
- int midy = (int) (pos.getMinY() + pos.getHeight() / 2);
- if (i.getIndex() == INTERFACE_PASSWORD_WINDOW) {
- mouse.click(minX(i), midy + random(-dy, dy), true);
- } else {
- mouse.click(midx + random(1, maxRandomX), midy + random(-dy, dy), true);
- }
- return true;
- }
- private int minX(RSComponent a) {
- int x = 0;
- Rectangle pos = a.getArea();
- int dx = (int) (pos.getWidth() - 4) / 2;
- int midx = (int) (pos.getMinX() + pos.getWidth() / 2);
- if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1)
- return 0;
- for (int i = 0; i < interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD).getText().length(); i++) {
- x += 11;
- }
- if (x > 44) {
- return (int) (pos.getMinX() + x + 15);
- } else {
- return midx + random(-dx, dx);
- }
- }
- private boolean atLoginScreen() {
- return interfaces.get(596).isValid();
- }
- private boolean isUsernameFilled(String Username) {
- String username = Username.replaceAll("_", " ").toLowerCase().trim();
- return interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_USERNAME).getText().toLowerCase().equalsIgnoreCase(username);
- }
- private boolean isPasswordFilled(String Password) {
- return interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD).getText().toLowerCase().length() == Password.length();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement