Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Sign in to follow this  
King Khurram

[SOLVED] Error when attempting to create an Instance of ABC2

Recommended Posts

Hello

I am currently making  a script, and I am at the point where I would like to add Antiban.

The problem is, after I attempt to create an instance of ABC2, i receive THIS error. Below is a snippet of the code.

public class AlKharidTanner extends Script {
    // ABCL2
    public static final ABC2Util abc_util = new ABC2Util();

I receive this error twice on the above code, and once in the import statement regarding ABCL2. If it helps, I also noticed that I could not find this specific class in the external library, as shown HERE.

Please, any help would be appreciated. I read three of Trilez's guides (Tutorial on how to script, Antiban1 and ABC2), and still could not find a way to solve this issue. If I also try to construct a variable, and try to access a method of ABC2, I cannot find it after the dot.

int run_at = this.abc_util.

Thank you in advance. Below is my entire code if needed.

package scripts;

import org.tribot.api.Clicking;
import org.tribot.api.DynamicClicking;
import org.tribot.api.General;
import org.tribot.api.Timing;
import org.tribot.api.input.Mouse;
import org.tribot.api.types.generic.Condition;
import org.tribot.api.util.ABC2Util;
import org.tribot.api2007.*;
import org.tribot.api2007.types.RSItem;
import org.tribot.api2007.types.RSNPC;
import org.tribot.api2007.types.RSTile;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

/**
 * Created by ____ on 2016-08-13.
 */

@ScriptManifest(authors = "fffff", name = "King Al Kharid Tanner v1.00", category = "Money")
public class AlKharidTanner extends Script {
    // ABCL2
    public static final ABC2Util abc_util = new ABC2Util();

    // DECLARATION + INITIALIZATION OF INTEGER CONSTANTS
    private static final int COIN_ID = 995;
    private static final int COWHIDE_ID = 1739;
    private static final int LEATHER_ID = 1741;
    private static final int HARD_LEATHER_ID = 1743;
    private static final int TANNER_NPC_ID = 3231;
    private static final int TANNING_INTERFACE_INDEX = 324;



    // For now, I will only declare one tile, as my knowledge regarding banning is low.
    // I HAVE ABSOLUTELY NO IDEA WHY I HAVE TO CONSTRUCT AN OBJECT HERE, DESPITE IT NOT BEING STATIC. ONLY THING I SEE
    //  DIFFERENT FROM OTHER CLASSES IS THAT THIS CLASS IS NOT FINAL.
    private static final RSTile TANNER_TILE = new RSTile(3274,3191,0);



    // MOUSE POSITIONS: SOFT LEATHER.
    private static final int MIN_X_SOFT_LEATHER = 73;
    private static final int MIN_Y_SOFT_LEATHER = 87;
    private static final int MAX_X_SOFT_LEATHER = 114;
    private static final int MAX_Y_SOFT_LEATHER = 121;


    // getMousePosition() consumes nothing, to produce an array with 2 element, indicating the coordinates where the
    //  mouse should click to tan hides.
    // getMousePosition: None -> Int[]
    private int[] getMousePosition(){
        int x_position = General.random(this.MIN_X_SOFT_LEATHER, this.MAX_X_SOFT_LEATHER);
        int y_position = General.random(this.MIN_Y_SOFT_LEATHER, this.MAX_Y_SOFT_LEATHER);

        int temp_array[] = {x_position, y_position};
        return temp_array;


    }


    // bank() consumes nothing to produce a boolean determining if we were successful in banking the items.
    // bank: None -> Bool
    private boolean bank(){
        // Open the bank
        Banking.openBank();

        // Let's ensure that the banking interface is actually opened.
        if (!Timing.waitCondition(new Condition() {
            @Override
            public boolean active() {
                return Banking.isBankScreenOpen();
            }}, General.random(2000, 3500))){

            // Banking interface has not opened. Return false, we were unable to bank.
            System.out.println("FAILED TO BANK");
            return false;
        }
        // Banking interface is opened now, commence the rest of the operation.

        // Deposit all items but coins in bank.
        Banking.depositAllExcept(COIN_ID);
        General.sleep(250, 1000);

        // Withdraw cowhides. The "0" indicates that we are going to "Withdraw all".
        if (!Banking.withdraw(0, COWHIDE_ID)){
            // Unable to withdraw items, return false.
            System.out.println("FAILED TO BANK");
            return false;
        }

        // Normal people dont close banking interface, so leave it open. Everything has been completed. Return true.
        System.out.println("SUCCESSFULLY BANKED");
        return true;

        // v1.00 Test results: Seems like no issue what so ever.
    }


    // inBank() consumes nothing to produce true if the player is near a bank, false otherwise.
    // inBank: None -> Bool
    private boolean inBank(){
        sleep(150);
        boolean in_bank = Banking.isInBank();

        System.out.println("Are we in the bank :" + in_bank);
        return in_bank;
    }


    // inTanner() consumes nothing to produce a boolean which indicates whether we are near the tanner or not.
    // inTanner: None -> Bool
    private boolean inTanner(){
        // Search to see if we can find the tanner
        final RSNPC[] tanner = NPCs.findNearest(TANNER_NPC_ID);

        // Did we find the tanner? Null check so we don't recieve a unbounded array error afterwards.
        if (tanner.length < 1){
            // Could not find the tanner. Return false.
            return false;
        }

        // Tanner is near us, let's check if he's on the screen. If he isn't turn camera towards him.
        if (!tanner[0].isOnScreen()){
            // we get the tile position of the tanner, and then turn the camera towards it.
            Camera.turnToTile(tanner[0].getPosition());
        }

        // Now, there are a few things we must consider:
            // We must wait, until the camera has fully moved before clicking.
            // Once camera has stopped, tanner may have moved away, therefore we have to do it again.

        // The Timing class has a method waitCondition which allows us to do this. It waits an alloted amount of time,
        //  in hope a certain condition will result in true. The condition we will use is if the tanner is on screen.
        //   if it doesn't happen in the alloted time, we will presume that we are not near the tanner, and return false.
        boolean test = (Timing.waitCondition(new Condition() {
            @Override
            public boolean active() {
                return tanner[0].isOnScreen();
            }
        }, General.random(3000, 4000)));
        System.out.println("Are we in the tanner: " + test);
        return test;


        // v1.00 Test results: Seems fine. An issue may occur because it turns to it, but tanner may move from screen +
        //  barely shows him.
    }


    // walkToTanner() consumes nothing to produce a booleans, that determines whether we were successful in walking
    //  towards the tanner.
    // walkToTanner: None -> Bool
    private boolean walkToTanner(){
        // Walk to the tanner tiles
        if (!WebWalking.walkTo(TANNER_TILE)){
            System.out.println("FAILED TO WALK TO TANNER");
            return false;
        }

        // Wait till we arive to the tile.
        if (!Timing.waitCondition(new Condition() {
            @Override
            public boolean active() {
                return inTanner();
            }
            }, General.random(8000, 13000))) {

            // Were unable to get near the tanner.
            System.out.println("FAILED TO WALK TO THE TANNER, DID NOT MAKE IT IN TANNER.");
            return false;
        }

        // We have made walked to the tanner, and are succesfully inside the tanner building, or near tanner. True.
        System.out.println("SUCCESFULLY WALKED TO TANNER.");
        return true;

        // v1.00 seems fine.
    }


    // walkToBank() consumes nothing to produce a boolean indicating whether we were successful with regards to walking
    //  to the bank.
    // walkToBank: None -> Bool
    private boolean walkToBank(){
        // Walk to the bank.
        WebWalking.walkToBank();

        // Ensure that we arrive at the bank.
        if (!Timing.waitCondition(new Condition() {
            @Override
            public boolean active() {
                return inBank();
            }
        }, General.random(8000, 13000))) {

            // Were unable to get near the banker.
            System.out.println("FAILED TO WALK TO THE BANK, DID NOT MAKE IT IN BANK.");
            return false;
        }

        System.out.println("SUCCESSFULLY WALKED TO THE BANK.");
        return true;

        //v1.00 seems fine.
    }


    // tan() consumes nothing to produce a boolean determining whether we were successful in tanning the hides or not.
    // tan: None -> Bool
    private boolean tan(){
        // We are at the tanning location. Time to turn hides into leather. We will begin by findin the NPC that tans.
        final RSNPC[] tanner = NPCs.findNearest(TANNER_NPC_ID);

        // Null check, check if we actually found him.
        if (tanner.length < 1){
            // We did not find the tanner, we cannot tan. Return false.
            return false;
        }

        // We found the tanner. Now let's try to get our stuff tanned.
        DynamicClicking.clickRSNPC(tanner[0], "Trade");

        // The following statements heavily rely on whether or on the correct interface is opened. Using the interface
        //  explorer, the tanners interface has an index value of 324. This will be used with conjuction with the
        //   Timing class to ensure that the interface is opened before we do the other statements.
        if (!Timing.waitCondition(new Condition() {
            @Override
            public boolean active() {
                return (Interfaces.isInterfaceValid(TANNING_INTERFACE_INDEX));
            }
        }, General.random(2500, 4000))){
            System.out.println("WE FAILED TO OPEN THE TANNING INTERFACE. RETURNING FALSE.");
            return false;
        }

        // We have successfully opened the tanning interface. Now, let's move the mouse to the soft leather section.
        int temp_pos[] = getMousePosition();
        int temp_x = temp_pos[0];
        int temp_y = temp_pos[1];

        General.sleep(1000,1500);
        Mouse.move(temp_x, temp_y);
        // perhaps needs a sleep?

        // We know should be hovering over the tanning option for soft leather. Lets tan all.
        Mouse.click(3);                     // Right clicks.
        ChooseOption.select("Tan All");     // Selects "Tan All" option.

        // We will now do one final check to ensure that our inventory is comprised of only leather and coins.
        //  This is so we 100% know if we successfully tanned. This will be done by checking if we have more than one
        //   leather within our inventory (as we started with 0. We will do this once the interface is closed, since
        //    it automatically closes when finished.

                /*if (Timing.waitCondition(new Condition() {
                    @Override
                    public boolean active() {
                        sleep(50);
                        return !(Interfaces.isInterfaceValid(TANNING_INTERFACE_INDEX));
                    }
                }, General.random(1000, 1200))){
                    // Interface is still valid, for whatever reason. We could close and try again, but for now, just return
                    //  false.
                    System.out.println("WE FAILED TO TAN");
                    return false;
                }*/

        General.sleep(1500, 3000);
        if (Inventory.getCount(this.LEATHER_ID) == 0){
            // We have FAILED TO tan, return false.
            System.out.println("FAILED TANNED. RETURNING FALSE.");
            return false;
        }

        // We have succesfully tanned, return true.
        System.out.println("SUCCESSFULLY TANNED. RETURNING TRUE.");
        return true;

        // v1.00 works beautifully. sOMETIMES doesnt click trade tanner.
    }


    // UNUSED ATM
    // invetoryCheck(RSItem[]) is a function that consumes a RSItem[] in order to determine how the script should begin.
    //  it produces nothing.
    // invetoryCheck: RSItem[] -> None
    private String inventoryCheck(RSItem[] inventory){
        // No items in inventory check.
        if (inventory.length < 1){
            // Go to bank and get your shit.
            return "Go to banker.";

        // Let's check if coins are even in the Inventory. If they are, check if we have cow-hides. If not, go to bank.
        } else if (coinInInvetory(inventory)){
            // Lets check if the inventory is comprised of only cowhides and coins.
            inventory = Inventory.filterDuplicates(inventory);

            if (inventory.length == 2 &&
                    ((Inventory.getCount(COWHIDE_ID)) > 1)){
                    // Now, so far, we have proved that there are coins in the inventory, and cowhides only. We are done
                    //  here. We just need to go to tanner. We can now enter the loop.
                    return "Go to Tanner.";
            }
        }
        return "Go to banker.";
    }


    // coinInInventory consumes an RSItem[] to produce a boolean, determining whether or not coins
    //  were found in the inventory.
    private boolean coinInInvetory(RSItem[] inventory){
        if ((Inventory.find(COIN_ID)).length >= 1){
            System.out.println("We found the coins.");
            return true;
        }else{
            System.out.println("No coins found.");
            return false;
        }
    }

    @Override
    public void run() {

        System.out.println("Initiating start up.");
        System.out.println("Please ensure that coins are in your inventory.");


        while (true){
            // For CPU.
            sleep(100);

            // First step should be identifying where you are, and doing the tasks accordingly. Let's check if we are
            //  at the bank. If we are, check if inventory is full of cowhides, leather, or neither.
            if (inBank()){
                // If we are in the bank, determine if we want to bank, or leave the bank.

                // If we have more than 1 leather in inventory, just go to bank and start from there.
                if (Inventory.getCount(COWHIDE_ID) > 1) {
                    walkToTanner();
                } else {
                    bank();
                }

            } else if (inTanner()){
                // Determine whether we already have tanned cowhides or not.

                // if we have cowhides, tan them.
                if (Inventory.getCount(COWHIDE_ID) > 1) {
                    tan();
                } else {
                    // We don't have any cowhides in inventory. Go to bank.
                    walkToBank();
                }

            } else {
                // You are in the middle of nowhere. Check if you need to go to the bank, or to the tanner.

                if (Inventory.getCount(COWHIDE_ID) > 1){
                    walkToTanner();
                } else {
                    walkToBank();
                }

            }
        }
    }
}

 

SOLUTION: Was using a depreciated class as c#2bot has stated. Used the appropriate class and import statement and it worked.

Edited by King Khurram

Share this post


Link to post
Share on other sites
Array

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 49 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 86 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 25 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...