rafomaniac Posted January 4, 2016 Posted January 4, 2016 Hello guys, I'm making my first script, which is a wine drinker. I think I'm getting everything right, however there's missing one part that I can't get to figure out (saw a bunch of tutorials, and it was really helpful ) How do I click on jugs of wine from inventory? I have this code for now import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Rafael", info = "My first script", name = "Bebe vinho", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Começar com 'jugs of wine' no banco de falador"); } private enum State { DRINK, BANK, WAIT }; private State getState() { if (inventory.contains("jug of wine")) return State.DRINK; if (!inventory.contains("jug of wine")) return State.BANK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case DRINK: if (!myPlayer().isAnimating()) { sleep(random(10, 150)); } break; case BANK: Entity bank = objects.closest("Bank booth"); if (!inventory.contains("jug of wine")) getBank().depositAll(); if (bank != null) { bank.interact("Bank"); sleep(random(500, 1300)); getBank().withdraw("Jug of wine", 28); } break; case WAIT: sleep(random(300, 1000)); break; } return random(500, 1800); } @Override public void onExit() { log("Script parado. Bebado o suficiente?"); } @Override public void onPaint(Graphics2D g) { } } Any anti-ban would be helpfull (and advices eheh) Again, It's my first script, complete noob, never had any computer language learned, sorry if it's rubbish
Acerd Posted January 4, 2016 Posted January 4, 2016 (edited) Use this: import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; @ScriptManifest(author = "Rafael", info = "My first script", name = "Bebe vinho", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Começar com 'jugs of wine' no banco de falador"); AntiBan(); } public void AntiBan() throws InterruptedException { switch (random(1, 35)) { case 1: equipment.openTab(); break; case 2: skills.open(); break; case 3: camera.movePitch(40 + (random(2, 80))); break; case 4: camera.moveYaw(110 + (random(20, 50))); break; } sleep(random(250, 750)); tabs.open(Tab.INVENTORY); } private enum State { DRINK, BANK, WAIT }; private State getState() { if (inventory.contains("Jug of wine") && !myPlayer().isAnimating()) return State.DRINK; if (!inventory.contains("Jug of wine")) return State.BANK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case DRINK: getInventory().interact("Drink", "Jug of wine"); sleep(random(10, 150)); break; case BANK: if (!getBank().isOpen()) { getBank().open(); new ConditionalSleep(500) { @Override public boolean condition() throws InterruptedException { return !getBank().isOpen(); } }.sleep(); } if (getBank().isOpen() && getInventory().isEmpty() && !getInventory().contains("Jug of wine") && getBank().contains("Jug of wine")) { getBank().withdrawAll("Jug of Wine"); } else if (getBank().isOpen() && !getInventory().isEmpty() && !getInventory().contains("Jug of wine") && getBank().contains("Jug of wine")) { getBank().depositAll(); getBank().withdrawAll("Jug of Wine"); } if (getBank().isOpen() && getInventory().contains("Jug of wine")) { getBank().close(); } break; case WAIT: sleep(random(300, 1000)); break; } return random(500, 1800); } @Override public void onExit() { log("Script parado. Bebado o suficiente?"); } @Override public void onPaint(Graphics2D g) { } } Also if you dont mind me asking , why a wine drinker? Edited January 5, 2016 by Assnerd 2
lisabe96 Posted January 5, 2016 Posted January 5, 2016 Use this: import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; @ScriptManifest(author = "Rafael", info = "My first script", name = "Bebe vinho", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Começar com 'jugs of wine' no banco de falador"); AntiBan(); } public void AntiBan() throws InterruptedException { switch (random(1, 35)) { case 1: equipment.openTab(); break; case 2: skills.open(); break; case 3: camera.movePitch(40 + (random(2, 80))); break; case 4: camera.moveYaw(110 + (random(20, 50))); break; } sleep(random(250, 750)); tabs.open(Tab.INVENTORY); } private enum State { DRINK, BANK, WAIT }; private State getState() { if (inventory.contains("Jug of wine") && !myPlayer().isAnimating()) return State.DRINK; if (!inventory.contains("Jug of wine")) return State.BANK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case DRINK: getInventory().interact("Drink", "Jug of wine"); sleep(random(10, 150)); break; case BANK: if (!getBank().isOpen()) { getBank().open(); new ConditionalSleep(500) { @Override public boolean condition() throws InterruptedException { return !getBank().isOpen(); } }.sleep(); } if (getBank().isOpen() && getInventory().isEmpty() && !getInventory().contains("Jug of wine") && getBank().contains("Jug of wine")) { getBank().withdrawAll("Jug of Wine"); } else if (getBank().isOpen() && !getInventory().isEmpty() && !getInventory().contains("Jug of wine") && getBank().contains("Jug of wine")) { getBank().depositAll(); getBank().withdrawAll("Jug of Wine"); } if (getBank().isOpen() && getInventory().contains("Jug of wine")) { getBank().close(); } break; case WAIT: sleep(random(300, 1000)); break; } return random(500, 1800); } @Override public void onExit() { log("Script parado. Bebado o suficiente?"); } @Override public void onPaint(Graphics2D g) { } } Also if you dont mind me asking , why a wine drinker? Because wine is 35gp and jug is ~85, with water 110 Its mad beginner cash
Acerd Posted January 5, 2016 Posted January 5, 2016 Because wine is 35gp and jug is ~85, with water 110 Its mad beginner cash interesting
rafomaniac Posted January 5, 2016 Author Posted January 5, 2016 I tought a wine drinker would be a decent script to start learning (actually learned a lot holy shiee....) next stop, is to get a jug filler, where it doesn't have 20 people getting jugs of water every hour jesus christ, and maybe I'll last a while longer money-making on F2P accounts eheh I'm thinking of doing a quester next
Acerd Posted January 5, 2016 Posted January 5, 2016 I tought a wine drinker would be a decent script to start learning (actually learned a lot holy shiee....) next stop, is to get a jug filler, where it doesn't have 20 people getting jugs of water every hour jesus christ, and maybe I'll last a while longer money-making on F2P accounts eheh I'm thinking of doing a quester next good luck 1