Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Sand Crabs ID's returning as Null


    Bladez
     Share

    Recommended Posts

    Hello guys, im trying to script a simple sandcrabs script that wakes up sleeping crabs.
    i've found the sandcrab ID's and tried to do a simple script to see if i can get the client to simply walk to the crabs but i'm getting nullpointer error codes in the log.

    
    

    GameObject rock = getGameObjects().closest(crab -> crab.getID() == 101 || crab.getID() == 103);

    if (rock != null) {
    getWalking().walk(rock);
    sleep(2000);
    }

    [/CODE]

    Does anyone know a work around for this?
    Many TIA

    Link to comment
    Share on other sites

    Ok i fixed it by researching the actual ID's by using:
     

            Tile rockLocation = new Tile(2676,3713,0);
            GameObject Rocklocation = getGameObjects().getTopObjectOnTile(rockLocation);

            if (!getLocalPlayer().isInCombat()) {

               int ID = Rocklocation.getID();
               log("Rock ID =" + ID);
               sleep(2000);
                 
                 sleep(2000);
            }

    The crabs seem to return many different ID's, so i compiled them all into:
    GameObject rock = getGameObjects().closest(crab -> crab.getID() 

    it seemed to be working with the new ID's but it sometimes just clicks random spots on the minimap. any ideas?

    Link to comment
    Share on other sites

    You can simply do:

     

    getGameObjects().closest(o -> o.getName().equals("Sandy rocks");

    Or swap out 'Sandy rocks' for the correct 'name' string.

    Link to comment
    Share on other sites

    Clicking on minimap sounds like walking.

    When are you doing this check? Maybe put a log event in here and check if it happens when your minimap is clickced.

    if (rock != null) {
    getWalking().walk(rock);
    sleep(2000);
    }

    getGameObjects().closest() can return objects relatively far away. There might be another rock further out that isn't obvious on screen.

    In addition to Pseudo's code I'd maybe add an area check

    getGameObjects().closest(o -> o.getName().equals("Sandy rocks") && YOUR_AREA.contains(o));
    Link to comment
    Share on other sites

    Cheers for the reply guys, the trouble is it sometimes finds a rock crab but then other times just spam clicks a random point on the minimap and just stands there doing nothing. Almost like its clicking a crab that hasn't spawned yet.

    using get getTopObjectOnTile() and dumping the ID's i found to the log i found all of these ID's when scanning different tiles with the sleeping crabs on.
    What happens is it will click the minimap and spam click one location, sometimes it gets the crab location right, other times its like its clicking an invisible crab that hasn't spawned yet or something.

    Also if you've been to rock crabs before you'll see that they aren't named if you hover your mouse over them it shows nothing to return a named string for:
     

    getName().equals("Sandy rocks")



    This is the code i have at the moment and as you can see using getTopObject rather than using the enitity tool returns quite a few ID's

            GameObject rock = getGameObjects().closest(crab -> crab.getID() == 4894 || crab.getID() == 3703 || crab.getID() == 3721 || crab.getID() == 4910 || crab.getID() == 4907 || crab.getID() == 4908 || crab.getID() == 4911 || crab.getID() == 4904 || crab.getID() == 4899 || crab.getID() == 4902);
            if (!getLocalPlayer().isInCombat() && rock != null && rock.exists() && rock.isOnScreen() && rock.distance() > 2) {
                 getWalking().walk(rock);
                 sleep(2000);
            }
            return 1000;
        }
    }

     

    Link to comment
    Share on other sites

    42 minutes ago, Bladez said:


    Also if you've been to rock crabs before you'll see that they aren't named if you hover your mouse over them it shows nothing to return a named string for.

    It doesn't show when you hover over it, but it does if you right click doesn't it. I haven't been there in a long time.

    Not sure if this will work as I don't have an account to test it.

    GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Sandy rocks"));
    
            if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2) {
                if	(getWalking().walk(crab)) {
                    sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000);
                }
            }

     

     

     

    Link to comment
    Share on other sites

    9 minutes ago, Shy said:

    It doesn't show when you hover over it, but it does if you right click doesn't it. I haven't been there in a long time.

    Not sure if this will work as I don't have an account to test it.

    GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Sandy rocks"));
    
            if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2) {
                if	(getWalking().walk(crab)) {
                    sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000);
                }
            }

    Ok i tried doing it this way, trouble is i'm at rock crabs in rellekka and it completely ignores the Rock crabs which are shown as Rocks when you right click them and goes for the mining nodes nearby.
     

    		GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks"));
    
            if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2) {
                if	(crab.interact()) {
                    sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000);
                }
            }

     

     

     

    Link to comment
    Share on other sites

    Then define an area that doesn't include the mine south of rock crabs(I assume that's what you're talking about), and check if the Game Object is in that area as was previously recommended. Though I think another problem is that some rocks are just rocks at rock crabs if I remember correctly.

    GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks") && rockCrabArea.contains(gameObject) && !gameObject.hasAction("Mine"));

     

     

     

    Edited by Shy
    Link to comment
    Share on other sites

    21 minutes ago, Shy said:

    Then define an area that doesn't include the mine south of rock crabs(I assume that's what you're talking about), and check if the Game Object is in that area as was previously recommended. Though I think another problem is that some rocks are just rocks at rock crabs if I remember correctly.

    GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks") && rockCrabArea.contains(gameObject) && !gameObject.hasAction("Mine"));

     

     

     

    still nothing, just stands there doing nothing now :( 
    I'm stumped.

     

    		GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks") && KILL_AREA.contains(gameObject) && !gameObject.hasAction("Mine"));
    
            if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2 && KILL_AREA.contains(crab)) {
                if	(crab.interact()) {
                    sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000);
                }
            }

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.