Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Script Created by: Duggypker
- //Requested by: Jaque
- //Have fun!
- package com.scripts;
- import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
- import com.kbot2.scriptable.Script;
- import com.kbot2.scriptable.methods.data.Walking;
- import com.kbot2.scriptable.methods.wrappers.NPC;
- import com.kbot2.scriptable.methods.wrappers.Obj;
- import com.kbot2.scriptable.methods.wrappers.Tile;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Graphics2D;
- public class DugsCheesyBuyer extends Script implements PaintListener{
- //=============
- // Variables
- //=============
- int boothID = 2213;
- int potatoe = 6705;
- int cookID = 4293;
- int coinID = 995;
- //===============
- //Paint Variables
- //===============
- long startTime = System.currentTimeMillis();
- String status = "Starting Up...";
- String minute;
- String second;
- String hour;
- private int PotCount;
- int CashCount;
- //=============
- //Paths
- //=============
- Tile[] toBank = new Tile[]{new Tile(2842,3552), new Tile(2840,3547), new Tile(2845,3547), new Tile(2845,3542), };
- Tile[] toStore = new Tile[]{new Tile(2843,3543), new Tile(2847,3546), new Tile(2842,3546), new Tile(2842,3551), };
- Tile inStore = new Tile(2842,3551);
- Tile inBank = new Tile(2845,3542);
- @Override
- public boolean active(){
- return true;
- }
- @Override
- public boolean onStart(){
- startTime = System.currentTimeMillis();
- return true;
- }
- public String getName() {
- return "DugsCheesyBuyer";
- }
- public String getAuthor() {
- return "Duggypker";
- }
- public double getVersion() {
- return 1.0;
- }
- public String getDescription() {
- return "Start in warriors guild either in bank or by the cook.";
- }
- @Override
- public void onStop(){
- log("Please vote whether or not I should release the"
- + " script to the publc or not :P");
- log("If you had no errors, then congratz, you got "
- + Integer.toString(PotCount) + " Potatoes and spent "
- + Integer.toString(CashCount) + " coins.");
- }
- void logOut() {
- if(isLoggedIn()){
- Point logoutButton1 = new Point(744, 5);
- Point logoutButton2 = new Point(579, 368);
- mouse.clickMouse(logoutButton1, 17, 14, true);
- sleep(random(250, 500));
- mouse.clickMouse(logoutButton2, 129, 16, true);
- }
- }
- public boolean isCollectionOpen() {
- Interface geInterface = interfaces.getInterface(109, 13);
- if (geInterface != null && geInterface.isValid()) { // GE
- log("Stupid collection box is opened. Closing...");
- geInterface.doClick();
- sleep(600, 1000);
- return true;
- }
- return false;
- }
- public int loop() {
- setMouseSpeed(random(1,5));
- if(walking.getEnergy() >= random(40, 100) && settings.getSetting(173) != 1){
- setMouseSpeed(random(1,5));
- walking.setRunning(true);
- }
- if(inventory.contains(coinID)){
- if(!inventory.isFull()){
- if(distanceTo(inStore) <= 4){
- setMouseSpeed(random(1,5));
- status = "Buying Cheesy Potatoes!";
- NPC cook = npcs.getClosest(7, cookID);
- cook.doAction("Trade");
- }
- if(interfaces.interfaceGroupExists(620)){
- setMouseSpeed(random(1,5));
- Point PotPoint = new Point(197, 108);
- mouse.clickMouse(PotPoint, 8, 11, false);
- sleep(random(250, 500));
- atMenu("X");
- mouse.setMouseSpeed(3);
- sleep(random(2000, 2500));
- sendText(Integer.toString(random(27, 38)), true);
- setMouseSpeed(random(1,5));
- sleep(random(1000, 1500));
- PotCount += inventory.getCount(false, potatoe);
- CashCount = PotCount * 350;
- }
- return 300;
- }
- if(distanceTo(inStore) <= 7){
- status = "Walking to store...";
- walking.walkToMM(inStore);
- return 300;
- }else if(distanceTo(inStore) > 5){
- status = "Walking to store...";
- try{
- walking.walkPath(toStore);
- return 300;
- }catch(Exception e){
- status = "Error!";
- log("Error walking: " + e.toString());
- }
- return 300;
- }
- }else{
- if(distanceTo(inBank) <= 4){
- setMouseSpeed(random(1,5));
- status = "Banking...";
- Obj Bank = getClosestObject(7, boothID);
- Bank.doAction("Use-");
- sleep(random(500, 1000));
- if(bank.isOpen()){
- setMouseSpeed(random(1,5));
- bank.depositAllExcept(coinID);
- sleep(random(500, 1000));
- bank.close();
- }
- return 300;
- }
- if(inventory.isFull() && distanceTo(inBank) > 4) {
- status = "Walking to bank...";
- walking.walkPath(toBank);
- }else{
- status = "Out of money. Logging out.";
- log("Out of money. Logging out. If you had money but it was accidentally banked,");
- log("If this happens over and over again. Please report it. ");
- logOut();
- stopAllScripts();
- }
- }
- return 300;
- }
- /* }else{
- interfaces.clickContinue();
- }
- return 300;*/
- public void onRepaint(Graphics g){
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- hour = Long.toString(hours);
- minute = Long.toString(minutes);
- second = Long.toString(seconds);
- String time1 = "";
- String time2 = "";
- String time3 = "";
- if(hours < 10){
- time1 = "0";
- }
- if(minutes < 10){
- time2 = "0";
- }
- if(seconds < 10){
- time3 = "0";
- }
- Graphics2D g2d = (Graphics2D) g;
- g2d.setColor(new Color(255, 255, 255, 100));
- g2d.fill3DRect(5, 269, 150, 69, true);
- g2d.setColor(Color.green);
- g2d.setFont(new Font("Comic Sans", Font.BOLD, 14));
- g2d.drawString("CheesyBuyer v" + getVersion(), 11, 285);
- g2d.setColor(Color.red);
- g2d.setFont(new Font("Arial", Font.PLAIN, 12));
- g2d.drawString("Potatoes bought: " + Integer.toString(PotCount), 9, 297);
- g2d.drawString("Time running: " + time1 + hours + ":" + time2 + minutes + ":" + time3 + seconds, 9, 309);
- g2d.drawString("Money spent: " + CashCount, 9, 321);
- g2d.drawString("Status: " + status, 9, 333);
- }
- }
Add Comment
Please, Sign In to add comment