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
  • [request] any updated guides to script with DB3's API? :D


    darkvenus

    Recommended Posts

    The principle is pretty much identical to that of writing scripts for DB2, the only real 'difference' is the conversion to a static API, so classes are accessed differently. For example:

     

    Put simply, Instead of using getPlayers()...method, you would use Players...method.

    Link to comment
    Share on other sites

    • 2 weeks later...

    First thing you should learn is how to use the dreambot's javadocs and understand it.

    1) Download a chrome extension called Javadoc Search Frame. This will help you navigate through the javadocs and find stuff easier.

    2) Understand what are constructors and methods. showing_javadocs.thumb.PNG.d3318a31f5e3a6dad1b3b631675aba0d.PNG

     

    3) For example you wanna get your character's combat level. You'd use the constructor "Player". And use a method called getLevel(). The code would look like this: log(Player.getLevel());

    4) Also what's really helpful is learning how to code in a node system kind of way, instead of writing linear, abstract scripts (they get pretty confusing real fast). It's better to have many classes and keep them as short as possible. 

    You can find some help on node systems here:

     

    Hope this helps you a bit. When I started, the biggest aha moment was learning what are constructors and methods. That started my scripting career.

    Link to comment
    Share on other sites

    50 minutes ago, una_maquina said:

    First thing you should learn is how to use the dreambot's javadocs and understand it.

    1) Download a chrome extension called Javadoc Search Frame. This will help you navigate through the javadocs and find stuff easier.

    2) Understand what are constructors and methods. showing_javadocs.thumb.PNG.d3318a31f5e3a6dad1b3b631675aba0d.PNG

     

    3) For example you wanna get your character's combat level. You'd use the constructor "Player". And use a method called getLevel(). The code would look like this: log(Player.getLevel());

    4) Also what's really helpful is learning how to code in a node system kind of way, instead of writing linear, abstract scripts (they get pretty confusing real fast). It's better to have many classes and keep them as short as possible. 

    You can find some help on node systems here:

     

    Hope this helps you a bit. When I started, the biggest aha moment was learning what are constructors and methods. That started my scripting career.

    Thanks bro that extension is really helpful, This is currently my goal, to learn how to script. I've read a lot throughout the forum and i've seen that node tutorial.

    I'll check him out asap, I managed to build some Woodcutting script. i'm trying to understand now how to do some actions to what I want to script. (thought of anti-pattern system, prioritize system and such)

    i like to start in the middle of the puzzle 😜 more interesting and fun.

    Link to comment
    Share on other sites

    6 minutes ago, darkvenus said:

    Thanks bro that extension is really helpful, This is currently my goal, to learn how to script. I've read a lot throughout the forum and i've seen that node tutorial.

    I'll check him out asap, I managed to build some Woodcutting script. i'm trying to understand now how to do some actions to what I want to script. (thought of anti-pattern system, prioritize system and such)

    i like to start in the middle of the puzzle 😜 more interesting and fun.

    For antiban compatibility, you'll most likely need to learn how the node system works. I just implemented it into my own code; you'll most likely not understand this, but I'll leave an explanation how I did it. In the main class where I go through the nodes, I've made an if statement, which checks if "run_anti_ban" static variable isn't true. If it's true, the main class won't run the nodes, and that will basically stop the main code.

     

    I have the antiban class as a thread, so whenever it finishes sleeping for a random amount, it'll change "run_anti_ban" variable into true and will run its own code in the meantime. After it finishes running antiban code, it'll change back the "run_anti_ban" variable into false again and go to sleep; and essentially let the main code run again. I also have all my variables stored into a different class called variables to keep it neat. Anyhow, good luck!

    Link to comment
    Share on other sites

    6 minutes ago, una_maquina said:

    For antiban compatibility, you'll most likely need to learn how the node system works. I just implemented it into my own code; you'll most likely not understand this, but I'll leave an explanation how I did it. In the main class where I go through the nodes, I've made an if statement, which checks if "run_anti_ban" static variable isn't true. If it's true, the main class won't run the nodes, and that will basically stop the main code.

     

    I have the antiban class as a thread, so whenever it finishes sleeping for a random amount, it'll change "run_anti_ban" variable into true and will run its own code in the meantime. After it finishes running antiban code, it'll change back the "run_anti_ban" variable into false again and go to sleep; and essentially let the main code run again. I also have all my variables stored into a different class called variables to keep it neat. Anyhow, good luck!

    Thanks much, I understand half of it theoretically. but i'll return to this comment in a couple of days when i'll have more knowledge about how nodes work and more😜 

    Link to comment
    Share on other sites

    3 hours ago, una_maquina said:

    3) For example you wanna get your character's combat level. You'd use the constructor "Player". And use a method called getLevel(). The code would look like this: log(Player.getLevel());

    No, you don't use the constructor of Player. If you used constructor, you'd be writing new Player(someReference).getLevel(), which you don't want to or can't do. When you write Player.getLevel() you call a static method getLevel inside the Player class (HOWEVER, getLevel is not a static method, so that doesn't work! To get your character's level, you'd use Players.getLocalPlayer().getLevel()). Nothing constructor related there.

    Here's an example of constructor usage. Say I want to walk to a certain location.

    1. I browse the javadocs to find that there's a walk method in Walking class
      kuva.png
    2. The method walk takes a Tile as a parameter. Then I click the link to Tile's javadocs page and notice it has three constructors
      kuva.png
    3. I can then use the walk method to walk to a certain tile by using one of the following
      1. Walking.walk(new Tile()), I didn't pass any coordinates to Tile's constructor, so it defaults them to 0 (not something you'd use)
      2. Walking.walk(new Tile(3284, 4310)), I used the second constructor that takes the tile's x and y coordinates
      3. Walking.walk(new Tile(3284, 4310, 1)), I used the third constructor that also has the z coordinate as a parameter
    Link to comment
    Share on other sites

    1 minute ago, Hashtag said:

    No, you don't use the constructor of Player. If you used constructor, you'd be writing new Player(someReference).getLevel(), which you don't want to or can't do. When you write Player.getLevel() you call a static method getLevel inside the Player class. Nothing constructor related there.

    Here's an example of constructor usage. Say I want to walk to a certain location.

    1. I browse the javadocs to find that there's a walk method in Walking class
      kuva.png
    2. The method walk takes a Tile as a parameter. Then I click the link to Tile's javadocs page and notice it has three constructors
      kuva.png
    3. I can then use the walk method to walk to a certain tile by using one of the following
      1. Walking.walk(new Tile()), I didn't pass any coordinates to Tile's constructor, so it defaults them to 0 (not something you'd use)
      2. Walking.walk(new Tile(3284, 4310)), I used the second constructor that takes the tile's x and y coordinates
      3. Walking.walk(new Tile(3284, 4310, 1)), I used the third constructor that also has the z coordinate as a paremeter

    I see, I've used constructor and class interchangeably, because I thought they're one and the same. Then I guess we're taking methods from classes and using constructors in the methods themselves.

    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.