Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. I'm glad you found it useful
  2. Thanks, i'll try and add something to prevent that from happening
  3. Thanks for the report, I am aware of the crafting issues for things like amulets, I'll get it fixed asap. Thanks
  4. Bot with items to trade: if inventory contains x items if bank is open close bank else if not in trade use trade interaction on target player sleep until in trade else if in trade with wrong player close trade else if on first trade screen if not offered x items offer x items else if not accepted accept trade else if on second screen if not accepted trade accept trade else if not bank is open open bank else if bank contains x items withdraw x items else stop Bot receiving items: bool trade On received message: if message is of type trade and message is from target player set trade to true On loop: if trade is true if not in trade do trade interaction with target player sleep until in trade else if not trading target player close trade else if on first window if other player accepted accept trade else if on second window if other player accepted accept trade set trade to false
  5. Take a look at the ServerSocket and Socket classes, there are plenty of examples online
  6. Indeed, I expected that OSBot would prevent you from executing files like that. Im not sure if there is a -allow CLI parameter for allowing such things, but I doubt it. You will need to figure out an alternative solution for muling For example you could write a server that listens on a socket, when it receives a message from your script it runs the muling script
  7. If you want to start another script you can do: List<String> command = new ArrayList<>(); Collections.addAll(command, "java", "-jar", "C:\\Path\\To\\OSBot.jar"); Collections.addAll(command, "-login", "username:password"); // add all the other parameters like above ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.start(); You can check out the source of my OSBot Manager to see how I did it: https://github.com/Explv/osbot_manager/blob/master/src/script_executor/ScriptExecutor.java If you really want to store it in a .bat file then you can do the same as above but replacing the command with: List<String> command = new ArrayList<>(); Collections.addAll(command, "cmd", "/c", "start"); command.add("C:\\Path\\To\\.bat");
  8. tl;dr It's all the same shit. The Area class has several contains methods: public boolean contains(Entity entity) { return contains(entity.getX(), entity.getY()) && plane == entity.getZ(); } public boolean contains(Position position) { return contains(position.getX(), position.getY()) && plane == position.getZ(); } public boolean contains(int x, int y, int z) { return contains(x, y) && plane == z; } public boolean contains(int x, int y) { return (new java.awt.geom.Area(polygon)).contains((double)x, (double)y); } So, when you call: area.contains(myPlayer()) That will call the contains(Entity entity) method, because the Player is an Entity, which will then call the contains(int x, int y) method with the x coordinate and y coordinate of that entity, and also check if the z vlaues are the same. When you call: area.contains(myPosition()) That will call the contains(Position position) method, which will then call the contains(int x, int y, int z) method using the x, y and z coordinates of that Position, which then will call the contains(int x, int y) method, and also check the z values are the same. Either way, they both end up calling the same method contains(int x, int y) which checks that the polygon of the Area contains those coordinates, and also check that the z value is the same.
  9. The player object for your own player can be accessed with: Player player = myPlayer(); The method: myPosition() Just does: myPlayer().getPosition()
  10. When I have tested everything fully and ironed out the bugs, then I will probably request it to be premium
  11. Thanks for the report, I will make sure it selects the inventory to prevent that happening. I will also try and add something to avoid that pesky Mugger
  12. No, it was removed from the API
  13. Are you sure the path is correct?
  14. You nearly did it correctly, I'm not sure if this is the best way (someone correct me if there is a better method) but what you can do is create a new folder in the artifact called "resources" and then add the contents of the resources folder in your project to that folder.Currently what you are doing is putting the contents of resources into your jar, but they will no longer be in a directory called resources. Sorry if that is unclear Also you do not need to include the OSBot jar in your artifact
  15. No you are correct, I will update it when I am home, thanks
  16. This is not the correct section for this question. Post on the script's thread. As for the error, the scripter is using functionality that is no longer present in the API as of the latest version
  17. You need to add the resources directory to the exported .jar file in the artifacts menu
  18. import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.event.Event; import org.osbot.rs07.input.mouse.RectangleDestination; import org.osbot.rs07.listener.LoginResponseCodeListener; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; public final class LoginEvent extends Event implements LoginResponseCodeListener { public enum LoginEventResult { UNEXPECTED_SERVER_ERROR(1, "Unexpected server error"), LOG_IN(2, "Log in"), INVALID_CREDENTIALS(3, "Invalid username or password"), BANNED(4, "Username is banned"), ACCOUNT_ALREADY_LOGGED_IN(5, "Account is already logged in try again in 60 seconds"), RUNESCAPE_UPDATED(6, "Runescape has been updated! Please reload this page."), WORLD_IS_FULL(7, "This world is full. Please use a different world."), LOGIN_SERVER_OFFLINE(8, "Unable to connect. login server offline."), TOO_MANY_CONNECTIONS_FROM_ADDRESS(9, "Login limit exceeded. Too many connections from you address."), BAD_SESSION_ID(10, "Unable to connect. Bad session id."), PASSWORD_CHANGE_REQUIRED(11, "We suspect someone knows your password. Press 'change your password' on the front page."), MEMBERS_ACCOUNT_REQUIRED(12, "You need a members account to login to this world. Please subscribe, or use a different world."), TRY_DIFFERENT_WORLD(13, "Could not complete login. Please try using a different world."), TRY_AGAIN(14, "The server is being updated. Please wait 1 minute and try again."), SERVER_UPDATE(15, "The server is being updated. Please wait 1 minute and try again."), TOO_MANY_INCORRECT_LOGINS(16, "Too many incorrect longs from your address. Please wait 5 minutes before trying again."), STANDING_IN_MEMBERS_ONLY_AREA(17, "You are standing in a members-only area. To play on this world move to a free area first."), ACCOUNT_LOCKED(18, "Account locked as we suspect it has been stolen. Press 'recover a locked account' on front page."), CLOSED_BETA(19, "This world is running a closed beta. sorry invited players only. please use a different world."), INVALID_LOGIN_SERVER(20, "Invalid loginserver requested please try using a different world."), PROFILE_WILL_BE_TRANSFERRED(21, "You have only just left another world. your profile will be transferred in 4seconds."), MALFORMED_LOGIN_PACKET(22, "Malformed login packet. Please try again"), NO_REPLY_FROM_LOGIN_SERVER(23, "No reply from loginserver. Please wait 1 minute and try again."), ERROR_LOADING_PROFILE(24, "Error loading your profile. please contact customer support."), UNEXPECTED_LOGIN_SERVER_RESPONSE(25, "Unexepected loginserver response"), COMPUTER_ADDRESS_BANNED(26, "This computers address has been blocked as it was used to break our rules."), SERVICE_UNAVAILABLE(27, "Service unavailable."); int code; String message; LoginEventResult(int code, String message) { this.code = code; this.message = message; } } private static final Map<Integer, LoginEventResult> responseCodeLoginResultMap = new HashMap<>(); static { for (LoginEventResult result : LoginEventResult.values()) { responseCodeLoginResultMap.put(result.code, result); } } private static final Rectangle TRY_AGAIN_BUTTON = new Rectangle(318, 262, 130, 26); private static final Rectangle LOGIN_BUTTON = new Rectangle(240, 310, 120, 20); private static final Rectangle EXISTING_USER_BUTTON = new Rectangle(400, 280, 120, 20); private static final Rectangle CANCEL_LOGIN_BUTTON = new Rectangle(398, 308, 126, 27); private static final Rectangle CANCEL_WORLD_SELECTOR_BUTTON = new Rectangle(712, 8, 42, 8); private final String username, password; private int maxRetries = 5; private LoginEventResult loginEventResult; private int retryNumber = 0; public LoginEvent(final String username, final String password) { this.username = username; this.password = password; setAsync(); } public LoginEvent(final String username, final String password, final int maxRetries) { this(username, password); this.maxRetries = maxRetries; } @Override public final int execute() throws InterruptedException { if (loginEventResult != null) { handleLoginResponse(); } if (retryNumber >= maxRetries) { setFailed(); } if (hasFailed()) { return 0; } if (!getBot().isLoaded()) { return 1000; } else if (getClient().isLoggedIn() && getLobbyButton() == null) { setFinished(); return 0; } if (getLobbyButton() != null) { clickLobbyButton(); } else if (isOnWorldSelectorScreen()) { cancelWorldSelection(); } else if (!isPasswordEmpty()) { clickButton(CANCEL_LOGIN_BUTTON); } else { login(); } return random(100, 150); } public LoginEventResult getLoginEventResult() { return loginEventResult; } private void handleLoginResponse() throws InterruptedException { switch (loginEventResult) { case BANNED: case PASSWORD_CHANGE_REQUIRED: case ACCOUNT_LOCKED: case COMPUTER_ADDRESS_BANNED: case UNEXPECTED_SERVER_ERROR: case INVALID_CREDENTIALS: case RUNESCAPE_UPDATED: case LOGIN_SERVER_OFFLINE: case TOO_MANY_CONNECTIONS_FROM_ADDRESS: case BAD_SESSION_ID: case UNEXPECTED_LOGIN_SERVER_RESPONSE: case SERVICE_UNAVAILABLE: case TOO_MANY_INCORRECT_LOGINS: case ERROR_LOADING_PROFILE: setFailed(); break; case ACCOUNT_ALREADY_LOGGED_IN: case TRY_AGAIN: case SERVER_UPDATE: case NO_REPLY_FROM_LOGIN_SERVER: case MALFORMED_LOGIN_PACKET: sleep(random((int)TimeUnit.MINUTES.toMillis(1), (int)TimeUnit.MINUTES.toMillis(2))); retryNumber++; break; case PROFILE_WILL_BE_TRANSFERRED: sleep(random((int)TimeUnit.SECONDS.toMillis(5),(int)TimeUnit.SECONDS.toMillis(10))); retryNumber++; break; case WORLD_IS_FULL: case TRY_DIFFERENT_WORLD: case CLOSED_BETA: case INVALID_LOGIN_SERVER: case MEMBERS_ACCOUNT_REQUIRED: case STANDING_IN_MEMBERS_ONLY_AREA: // Should hop to a different world here setFailed(); break; } } private boolean isOnWorldSelectorScreen() { return getColorPicker().isColorAt(50, 50, Color.BLACK); } private void cancelWorldSelection() { if (clickButton(CANCEL_WORLD_SELECTOR_BUTTON)) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return !isOnWorldSelectorScreen(); } }.sleep(); } } private boolean isPasswordEmpty() { return !getColorPicker().isColorAt(350, 260, Color.WHITE); } private void login() { switch (getClient().getLoginUIState()) { case 0: clickButton(EXISTING_USER_BUTTON); break; case 1: clickButton(LOGIN_BUTTON); break; case 2: enterUserDetails(); break; case 3: clickButton(TRY_AGAIN_BUTTON); break; } } private void enterUserDetails() { if (!getKeyboard().typeString(username)) { return; } if (!getKeyboard().typeString(password)) { return; } new ConditionalSleep(30_000) { @Override public boolean condition() throws InterruptedException { return getLobbyButton() != null || getClient().isLoggedIn() || getClient().getLoginUIState() == 3 || loginEventResult == LoginEventResult.BANNED || loginEventResult == LoginEventResult.ACCOUNT_LOCKED; } }.sleep(); } private void clickLobbyButton() { if (getLobbyButton() != null && getLobbyButton().interact()) { new ConditionalSleep(10_000) { @Override public boolean condition() throws InterruptedException { return getLobbyButton() == null; } }.sleep(); } } private RS2Widget getLobbyButton() { try { return getWidgets().getWidgetContainingText("CLICK HERE TO PLAY"); } catch (NullPointerException e) { return null; } } private boolean clickButton(final Rectangle rectangle) { return getMouse().click(new RectangleDestination(getBot(), rectangle)); } @Override public final void onResponseCode(final int responseCode) { if (!responseCodeLoginResultMap.containsKey(responseCode)) { log("Got unknown login response code " + responseCode); setFailed(); return; } this.loginEventResult = responseCodeLoginResultMap.get(responseCode); log(String.format("Got login response: %d '%s'", responseCode, loginEventResult.message)); } } Usage example: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Explv", name = "Login Test", version = 0.1, logo = "", info = "") public class TestScript extends Script { private LoginEvent loginEvent; @Override public void onStart() { if (getClient().isLoggedIn()) { getLogoutTab().logOut(); } loginToAccount("username", "password"); } @Override public int onLoop() throws InterruptedException { if (loginEvent != null ) { if (loginEvent.isQueued() || loginEvent.isWorking()) { log("LoginEvent is running, script is idle"); return 2000; } if (loginEvent.hasFailed()) { stop(); } getBot().removeLoginListener(loginEvent); loginEvent = null; } log("Script is doing scripty things"); return 2000; } private void loginToAccount(String username, String password) { loginEvent = new LoginEvent(username, password); getBot().addLoginListener(loginEvent); execute(loginEvent); } } OSBot must be run with random events disabled, for example: java -jar "OSBot 2.5.59.jar" -allow norandoms
  19. It seems to work for me. Try running OSBot from the command line in debug mode so you can see any error output from saving/loading. It will help me to know what error you get exactly. You can run OSBot in debug mode by opening CMD / Terminal and typing the command: java -jar "C:\Users\Username\OSBotLocation\OSBot.jar" -debug Replacing the path with the path to your OSBot.jar file Thanks
  20. This is not the correct section for this question.
  21. Just FYI the: !cow.isUnderAttack() && cow.getHealthPercent() > 0 Is redundant because: cow.isAttackable() Does: npc.getHealthPercent() > 0 && !npc.isUnderAttack() || npc.isInteracting(getMethods().myPlayer()) As for your issue you could try doing: NPC cow = getNpcs().closest(npc -> npc.getName().startsWith("Cow") && cowArea.contains(npc) && npc.isAttackable() && npc.getInteracting() == null);
  22. 1. There is even a video tutorial for setting up OSBot with Intellij: https://www.youtube.com/watch?v=0mIWSUHXB9c 2 & 3. So it's just the layout that you think is harder on Intellij? The layout looks pretty damn similar to me Intellij: Eclipse:
×
×
  • Create New...