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
  • Checking if gameobject is gone.


    dirtrider478
     Share

    Recommended Posts

    //Get object and its unique index
    GameObject obj = GameObjects.closest(objId);
    int objIndex = obj.getIndex();
    
    ...
    
    //Check if obj is gone
    boolean objGone = GameObjects.closest(obj -> obj != null && obj.getID() == objId && obj.getIndex() == objIndex) == null;

    This is what I do if there's multiple game objects of the same type around. If it's the only one in the vicinity you can just leave out the index part

     

    Link to comment
    Share on other sites

    20 minutes ago, SubCZ said:
    //Get object and its unique index
    GameObject obj = GameObjects.closest(objId);
    int objIndex = obj.getIndex();
    
    ...
    
    //Check if obj is gone
    boolean objGone = GameObjects.closest(obj -> obj != null && obj.getID() == objId && obj.getIndex() == objIndex) == null;

    This is what I do if there's multiple game objects of the same type around. If it's the only one in the vicinity you can just leave out the index part

     

    You could also use GameObject#exists:

    GameObject obj = GameObjects.closest("Whatever");
    
    // Later on...
    
    if (obj.exists()) {
    	// Object still exists
    } else {
    	// Object doesn't exist
    }

     

    Link to comment
    Share on other sites

    • 5 months later...
    On 12/28/2020 at 9:24 PM, Pandemic said:

    You could also use GameObject#exists:

    GameObject obj = GameObjects.closest("Whatever");
    
    // Later on...
    
    if (obj.exists()) {
    	// Object still exists
    } else {
    	// Object doesn't exist
    }

     

    What about if there's multiple game objects of the same type around

    Link to comment
    Share on other sites

    There is 3 rocks i want to know when its exists and if i interacting one i can chech when its not exist but if other player interact another rock how can i know when it not exists

    Link to comment
    Share on other sites

    On 12/28/2020 at 9:24 PM, Pandemic said:

    You could also use GameObject#exists:

    GameObject obj = GameObjects.closest("Whatever");
    
    // Later on...
    
    if (obj.exists()) {
    	// Object still exists
    } else {
    	// Object doesn't exist
    }

     

    @Pandemic

    What about  multiple game objects of the same type around

    Link to comment
    Share on other sites

    • 4 weeks later...
    On 6/16/2021 at 12:15 PM, TheCloakdOne said:

    You could either get the rock based on its tile, or store each rock in a var each time you loop and check each var if it exists

    How can I store rock in var ?

    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.