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
  • Kebab Finesser Snippet (Very basic script)


    Shunrai
     Share

    Recommended Posts

    Hello lads! I am quite new to scripting in Java and DreamBot but I made a simple Kebab Buyer and Banker today and decided to share it with you for feedback, even though it's not something special and I feel quite embarrassed for even posting it, here it is! It has a camera randomizer (Made in a quite basic way, there's probably a more efficient one) when it gets to Karim, will sometimes afk based on the randomizer I implemented in it.

    package DonerFinesser;
    
    import org.dreambot.api.Client;
    import org.dreambot.api.input.Mouse;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodProvider;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.container.impl.Shop;
    import org.dreambot.api.methods.container.impl.bank.Bank;
    import org.dreambot.api.methods.dialogues.Dialogues;
    import org.dreambot.api.methods.input.Camera;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.methods.interactive.Players;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.NPC;
    
    
    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.io.IOException;
    import java.net.URL;
    
    @ScriptManifest(category = Category.MONEYMAKING, name = "Kebab Finesser", author = "Shunrai#4174", version = 1.0)
    public class KebabFinesser extends AbstractScript {
        int karimcam = 0;
        int bruh = 0;
        int bruh2 = 0;
        int bruh3 = 0;
        int bruh4 = 0;
    int kebabsfinessed = 0;
        private Timer timer;
        private Image image;
    
    
    
    
    
        @Override
        public void onStart() {
            timer = new Timer();
            try {
                image = ImageIO.read(new URL("https://i.imgur.com/CIL79ag.png"));
            } catch(IOException e){
                log("Failed to load image");
            }
            log("Hi");
        }
    
        @Override
        public void onPaint(Graphics g) {
            if (image != null) {
                g.drawImage(image, 0, 430, null);
                g.setColor(Color.RED);
                g.setFont(new Font( "Times New Roman", Font.BOLD, 16));
                g.drawString("Shunrai go BRRRRrrrrr....", 5, 482);
                g.drawString("Kebabs Finessed:" + kebabsfinessed, 5, 522);
                g.drawString("Time:" + timer.formatTime(), 5, 552);
            }
        }
    
    
    
    
    
    
    
        @Override
        public int onLoop() {
            NPC karim;
            Area area = new Area(3271, 3182, 3275, 3179);
            if (Inventory.isFull()) {
                log("Attempting to bank");
                if (!Bank.isOpen()) {
                    Bank.openClosest();
                    return(Calculations.random(765, 1892));
                }
                if(Bank.isOpen()) {
                    if(Inventory.isFull()) {
                        Bank.depositAllExcept(995);
                    }
                }
            }
    
            if(Bank.isOpen() && !Inventory.contains(1971)) {
                Bank.close();
                karimcam = 1;
                ///random breaks
                bruh3++;
                if (bruh3 > 10){
                    bruh4++;
                    if (bruh4 < (Calculations.random(-5, 11)) || bruh4 > 11){
                        bruh3 = 0;
                        bruh4 = 0;
                        return(Calculations.random(30000, 70000));
                    }
                }
                ///
    
                return (Calculations.random(765, 1892));
            }
    
    
            if (!area.contains(Players.localPlayer().getTile())) {
                Walking.walk(area.getRandomTile());
                return(Calculations.random(800, 2000));
            }
    
            if (karimcam == 0) {
                Tile karimTile = NPCs.closest("Karim").getTile();
                Camera.mouseRotateToTile((new Tile(karimTile.getX() + Calculations.random(-2, 3), karimTile.getY() + Calculations.random(-2, 3))));
           karimcam = 1;
            }
    
    
    
            if (!Dialogues.inDialogue()) {
                karim = NPCs.closest("Karim");
    
             if (karim != null && karim.exists()) {
    
                    karim.interact("Talk-to");
                    Mouse.move();
                    sleepUntil(() -> getLocalPlayer().getHealthPercent() < 25 || Dialogues.inDialogue(), 6000);
                    return(Calculations.random(200, 500));
                }
            }
           if (Dialogues.inDialogue()){
               log("In dialogue boi");
               if (Dialogues.canContinue()){
                   Dialogues.continueDialogue();
                   return(Calculations.random(200, 500));
               }
               if (Dialogues.getOptions() != null){
                   Dialogues.typeOption(2);
                   ///random breaks
                   bruh++;
                   if (bruh > 40){
                       bruh2++;
                       if (bruh2 < (Calculations.random(-5, 11)) || bruh2 > 11){
                           bruh = 0;
                           bruh2 = 0;
                           return(Calculations.random(10000, 20000));
                       }
                   }
                   ///
                   kebabsfinessed++;
                   return(Calculations.random(100, 400));
               }
           }
           else {
               log("Not in dialog");
           }
    return 400;
        }
    }

     

    Edited by Shunrai
    Link to comment
    Share on other sites

    Not sure what your script do (Don't know what's the deal with the Kebab.
    I am also new here so, but I have experience as a programmer, so my comments are more about design.

    1.  Always assume that someone else need to read your code and understand it.  Why?
      1. Think about you in a year, will you remember everything here? for example this 'Bank.depositAllExcept(995);'?
      2.  When you work with others, you save them a lot of time when your code is clear and understandable.
    2.  Use global constants for .. constants :) 

      

    What you need to do? 

    1. More comments. I have no clue what the randoms breaks do. 
    2.  Better naming (area of what? what is it bruh?). 
    3.  Extract to global constant: area (And give it a clear name), dialog option (With Name of what this option do), action 'Talk-to',  every inventory item (You can use strings, but even if you use  string extract it to global), Maybe also Karim himself.
    4. You wrote everything in a big loop, you can extract some of it to functions that can be reusable in other places.
      For example depositToBank(Bank bank, List<Item> ItemsToKeep) which can be reusable in many scripts.

    It's looks cool in general, and you getting good skills here, good job and good luck :)

     

    Edited by mad man
    Link to comment
    Share on other sites

    1 hour ago, mad man said:

    Not sure what your script do (Don't know what's the deal with the Kebab.
    I am also new here so, but I have experience as a programmer, so my comments are more about design.

    1.  Always assume that someone else need to read your code and understand it.  Why?
      1. Think about you in a year, will you remember everything here? for example this 'Bank.depositAllExcept(995);'?
      2.  When you work with others, you save them a lot of time when your code is clear and understandable.
    2.  Use global constants for .. constants :) 

      

    What you need to do? 

    1. More comments. I have no clue what the randoms breaks do. 
    2.  Better naming (area of what? what is it bruh?). 
    3.  Extract to global constant: area (And give it a clear name), dialog option (With Name of what this option do), action 'Talk-to',  every inventory item (You can use strings, but even if you use  string extract it to global), Maybe also Karim himself.
    4. You wrote everything in a big loop, you can extract some of it to functions that can be reusable in other places.
      For example depositToBank(Bank bank, List<Item> ItemsToKeep) which can be reusable in many scripts.

    It's looks cool in general, and you getting good skills here, good job and good luck :)

     

    Oh, I din't think about any of this. Thank you! Will try naming my stuff and labeling it better if I post something next time! <3

    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.