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
  • Code snippet for Handling Random events (npcs that appear like your mother behind you and suddenly)


    Recommended Posts

    I made this and was using it in my code that I was writing, decided to take another path, and vs it going to waste figured it might be useful for someone it works... but not efficiently really you might need to modify the code for your own purpose, also like I said its not efficient really and I know this there are better ways to handle the !avoidHandler if statement than checking if the string is not empty xD, but ill leave that up to you.

    import org.dreambot.api.Client;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.wrappers.interactive.NPC;
    public class RandomEventHandler {
        public static void npcHandler(){
            String[] avoidHandler = {"Genie", "Bee keeper" , "Capt' Arnav", "Niles", "Miles", "Giles", "Sergeant Damien", "Drunken dwarf", "Evil Bob", "Servant", "Postie Pete", "Molly", "Freaky Forester", "Leo", "Jekyll and Hyde", "Frog prince", "Frog princess", "Frog", "Mysterious Old Man", "Pillory Guard", "Flippa", "Tilt", "Prison Pete", "Quiz Master", "Rick Turpentine", "Sandwich lady", "Strange plant", "Dunce", "Mr. Mordaut"};
            int arrayLength = avoidHandler.length;
            for (int i = 0; i < arrayLength; i++){
                if (!avoidHandler[i].isEmpty()){
                    NPC eventTrigger = NPCs.closest(avoidHandler[i]);


    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

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