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
  • ALL null instances of rat npc?!


    JAG98

    Recommended Posts

    In tutorial island. Wrote a script for attacking rats. Seems ALL the rats are null?
     

    Spoiler
    
    private void attackRat(){
        log("Attacking rat");
        if(getLocalPlayer().isInCombat()){
            log("Still Attacking!");
            sleepUntil(()-> !getLocalPlayer().isInCombat(), Calculations.random(1000, 2000));
        }
        else{
            log("Selecting rat");
            NPC rat = NPCs.closest(npc -> npc != null && npc.getName().equals("Giant Rat"));
            log("Rat selected");
            if(rat !=null){
                log("Not null rat!");
                if(rat.interact("Attack")){
                    sleepUntil(()-> !rat.exists(), Calculations.random(1000,2000));
                }
            }
        }
    }

    Tried replacing NPC with GameObject. Still no change.

    Logs only shows "Attacking rat", "Selecting rat", "Rat selected"

    Link to comment
    Share on other sites

    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.