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


    dirtrider478

    Recommended Posts

    Posted

    Im working on a script and am wondering if once a gameobject is found and clicked on is there a way to check if that specific gameobject I just clicked on is still there.

    Posted
    //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

     

    Posted
    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
    }

     

    • 5 months later...
    Posted
    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

    Posted

    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

    Posted
    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

    Posted

    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

    • 4 weeks later...
    Posted
    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 ?

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.