• Log in or sign up for an account here: https://www.sythe.org/login

How To Create A Rsbot ( Java Script )

Status
Not open for further replies.
Joined
Jul 5, 2008
Sythe Gold
0
Messages
316
Location
France
Hello And Welcome To My Little Guide TO Help you make your First script :)

Chapters :

1.Script Outline
2.walking
3.Object And NPC finding


______________


CHAPTER 1
:


This is a blank and most basic script. A new script must follow this format for it to be able to compile. It must implement all methods here.


Code:
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;



public class blank extends Script{

    public String getName() {
        return "Basic Script";
    }



    public String getAuthor() {
        return "~alex~";
    }

    public double getVersion() {
        return 0;
    }

    public boolean onStart(String[] args) {
        return true;
    }

    public int loop() {
        return 0;
    }

}


Thanks For ~ Alex ~ for The Skeleton !



___________________________________________



Chapter 2
:


walking
Making a script walking from location to location is easy in RsBot. Because it has the ability to read data from the client it can use Tiles for walking. In this tutorial I'm going to be showing you how to create an RSTilePath and use that to walk to a location.

Firstly I'm going to create a blank script

Now we will declare a new array of tiles. If you do not understand what an array is I suggest you Google it :D.

(
Code:
RSTile[] myTile = new RSTile[]{};

Now we need to get the tiles we want. To do this load up RsBot and start a bot. Ensure that player position is selected as the debug menu. You can see your players' current coordinates printed on the applet. Collect some coordinates and note them down. Here is a list that I've collected:

3222,3219
3235,3223
3230,3231
3221,3239
3215,3243
These are a series of waypoints from lumbridge castle to the general store. Now we will add these to our array of RSTiles.

Code:
RSTile[] myTiles = new RSTile[]{new RSTile(3222,3219),new RSTile(3235,3223),
    new RSTile(3230,3231),new RSTile(3221,3239),new RSTile(3215,3243)};

Now we will create a new variable, a RSTilePath. The parameters for a RSTile path are as follows: RsTilePath myPath = new RsTilePath(RSTile[],script);

Code:
RSTilePath myPath = new RSTilePath(myTiles,this);


Congratulations, you've just created your first path! Now I'm going to show you how to use this for walking, which is extremely simple.

Code:
myPath.walkToEnd();
myPath.walkToStart();


Something to note is that when walking a path an InterruptedException can be thrown, you must encapsulate your code in a try/catch block. Here is an example of it in a script:


Code:
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;

public class walking extends Script {

	RSTile[] myTiles = new RSTile[] {
			new RSTile(3222, 3219),
			new RSTile(3235, 3223), // We declare a new array of RSTile and
									// populate it with the waypoints
			new RSTile(3230, 3231), new RSTile(3221, 3239),
			new RSTile(3215, 3243) };// for our path.

	RSTilePath myPath = new RSTilePath(myTiles, this); // We declare a new
														// RSTilePath and tell
														// it to use the tiles
														// stores in 'myTiles'

	public String getName() {
		return "Basic Script";
	}

	public String getAuthor() {
		return "~alex~";
	}

	public double getVersion() {
		return 0;
	}

	public boolean onStart(String[] args) {
		return true;
	}

	public int loop() {
		try {
			myPath.walkToEnd();
			myPath.walkToStart();
		} catch (Exception e) {
			log("An error occured whilst walking");
		}
		return -1;
	}

}



Chapter 2 DONE !




________________________________-


Chapter 3



Object & Npc finding

These two topics are very similar so I decided to include them in the same tutorial.

The ability to find objects on screen instantaneously has been a key factor to RSBot's success. An object is model displayed in the client, for example a door or a bank booth. Each of these have a unique ID. When you log into RS through RSBot and turn on the object debug you will see white text displaying a number over every object. RSBot can use these ID's to scan all the objects on screen and find the one you are looking for. Open a blank script.

Now I'm going to intorduce you to a new class; the RSObject class. Lets attempt to find a bank booth at Draynor Bank. First of all we need to log into RSBot and ensure that the 'Object' option is enabled in the debug drop down menu. Now go to Draynor Bank and look at the number on top of the open bank booth. You should see that its 2213. We can now create a new RSObject for this object

Code:
RSObject bankBooth = new findObject(2213);



Now we've created a new RSObject we can use it to find the object on screen. In order to do this we must use the atObject method, like so.

Code:
public int loop() {
    	atObject(bankBooth, "quickly");
        return 0;
}

If you run that it will right click the bank booth and click quickly.



Now on to NPC's. NPC finding is similar to Object finding. They both have unique ID's however you can also find an NPC via it's name rather than it's ID. Try this,


Code:
public int loop() {
    	RSNPC man = getNearestNPCByName("Man");
    	return 0;
}


In eclipse you can then type 'man.' and the intelli-sense will show you all the methods within the RSNPC class. For instance you can do man.getAnimation(); or man.getHP();



In order to click a NPC you can use the atNPC method as follows,

Code:
RSNPC man = getNearestNPCByName("Man");
  atNPC(man, "Attack");

Try experimenting with these methods, especially with the RSNPC class. They are very powerful and you can do a lot with them.





Thats all and sorry its too short ill try to get more












Credits for ~alex~ The orignal Creater
 
It looks pretty good so far. I would like to see it when you add more:) .
 
Not bad, but a retarded baby could make a decent RSBot script w/o much trouble ;)
 
MASSIVE VOUCH FOR OMFGZOMFGLOL I LOVE U OMG I LOVE AHHHHHHHHH THANKS SO MUCH I LOVE U AHHHHHHHHHHHHHHHHHHHHHH
 
This is really great, but you could have went in depth on each variable or w/e.

Once you read this I recommend deciphering others code
 
woow ty so much !!!

but what to do if u want to make a willow cuter or a miner how does it know if invertory is full or not

-- edit--

what to do whit this code ??
myPath.walkToEnd();
myPath.walkToStart();

myPath.walkToEnd(); this above me paths ??
and this one myPath.walkToStart(); on the end ??
 
woow ty so much !!!

but what to do if u want to make a willow cuter or a miner how does it know if invertory is full or not

-- edit--

what to do whit this code ??
myPath.walkToEnd();
myPath.walkToStart();

myPath.walkToEnd(); this above me paths ??
and this one myPath.walkToStart(); on the end ??


Hello And im very glad To help you :)

1. About The How to know if inv is full :

Use This code :

Code:
                if(getInventoryCount(Logs) == 28){ //If we have an Empty inv. go to next step


2. Those Two ARe The Codes You Put in A Place in your Script
Example : after cutting willows and have full inventory You put one of those lines and it well walk the path for u :)

hope i helped and feel free to ask any more questions
 
Hello And im very glad To help you :)

1. About The How to know if inv is full :

Use This code :

Code:
                if(getInventoryCount(Logs) == 28){ //If we have an Empty inv. go to next step


2. Those Two ARe The Codes You Put in A Place in your Script
Example : after cutting willows and have full inventory You put one of those lines and it well walk the path for u :)

hope i helped and feel free to ask any more questions


woow ty again if i am stuck again i ll post/pm you =]
btw rsbot is offline ??
 
Is there any kind of manual for RSBot? I script SRL a lot, but i figured i might as well take a look at this :D
 
Status
Not open for further replies.
duelarena.gg
Back
Top