Complete Guide to Rsbot.

0 comments

Chapters
1. How to get RsBot
2. How to run RsBot
3. How to save .java files
4. How to Compile new scripts
5. How to add your bank pin to Rsbot

1. How to get RsBot

Firstly, download the most recent version from here:

rsbotsvn - Google Code

Once the download has finished you will have a .zip file. This needs to be extracted. To do this download WinRAR (http://www.rarlabs.com/rar/wrar380.exe ) and install it.








Next go to the file which you originally download, the Rsbot one. Right click it and you should see an "Extract to (name and version)"




After it has extract you will have a new folder called "RSBot", go in to it and you should see something like this:



2. How to run RsBot

Now that you have downloaded RsBot and extracted the folder you will have something like below.




To run a non-members world double click this batch file:



To run a members world double click this batch file:



If you're receiving "could not find main class" you must compile all of your files first, using the compile all.bat file.

If you are receiving an error, such as Java cannot be recognised, or you are missing tools.jar, please skip to 4. How to Compile new scripts.

Now rsbot should load and look like this.



In order to run a script you must click the Bot tab, then click run.




If this is your first time running rsbot you should now see the following image. Hit Ok



The following box will then open up and you must put in your account information by clicking Add. Then changing the defaults. Where it says "empty" place your RuneScape username and where it says "NOT SET" place your RuneScape password


After clicking Apply and Okay go back to Bot, then click Run again now a selection of scripts for you to use will open up, like this:



Once you've chosen a script you will have to define the arguements. This is what the bot will do, if it's a combat bot you can set it to eat, or to die and walk back to the monsters. Once you have chosen your settings and your account click Okay and the bot will log you in and get to work, provided you are in the correct place and with the correct items

3. How to save .java files

Found a new script you want to run but don't know what to do with it? Well I'll explain it all here

Firstly, look through the forums until you find a script you want. I'm going to use Zachafer's Auto Alcher as an example.


Copy the code which is given in the post. It's in a code tag so you can't miss it.

Next go to your Start menu, Programs, Accessories and click on Notepad, paste the code in there.

Now choose File, Save As... and look at the image below



Next click save, make sure you save it in the Scripts folder in the rsbot folder. If not save it to your desktop, go in to your rsbot folder and find this:



Copy and paste the .java file in to there and compile your scripts. Then run rsbot and your script will be in your script selector

4. How to Compile new scripts
In order to be able to compile scripts, using the compile all.bat you must first download Java JRE/JDK.
To download it follow this link:

Java SE Downloads - Sun Developer Network (SDN)


Look at the image below and click download


Agree to the terms and click continue. If you have Vista 64 bit, choose Windows x64 from the drop down menu.

Now right click the click and choose Save as.



Then click next:


Once it's installed click Finish


Well done you've successfully installed Java JDK!

Now for the next part, compiling.


In order to compile your scripts you must first download the script in .java format. Follow part 3 on How to save .java files.
Once you have the .java file and you've added it to your scripts folder, all you need to do is compile it.

To do this you must double click the compile all.bat in your rsbot folder. If you receive an error such as Java is not recognised, or Cannot find tools.jar follow these steps.

Cannot find tools.jar and Java cannot be recognised

In order to fix this you must have already installed Java JDK. If you have you now need to set your environment variables. Follow these steps to do so:
1. Go to My Computer then choose your hard drive, go to Program Files then Java.
2. Inside the Java folder your should see another folder called jdk1.6, go in to it, then go in to the "Bin" folder.
3. Right click any file in the folder and choose properties.
4. Next to Location on the new window that pops up it will show you the path to that file, copy it.
5. Go to Control Panel then double click System, choose the advanced tab then click Environment Variables.
6. In System Variables choose "Path" and click edit.
7. Now add a Semi Colon ( ; ) to the end of whatever is in it. Then simply paste the Path you copied earlier.
8. It should look like this


9. Now hit enter 3 times and restart your PC.
Now that the errors are solved Compile all.bat should work giving you a screen which looks similar to this


This means the scripts for Rsbot were successfully compiled and you may now run Rsbot and use them

Note: If you receive any kind of error saying could it could not compile because of a faulty .java file, you will have to fix the error, or delete it for the compiler to work successfully

In order to find out which category the new script(s) are in you must open the .java file and search for

Code:
public String getScriptCategory() {
Underneath you will see something like this
Code:
return "Fishing";
This means the script can be found in the Fishing category. To find what the script is called search for
Code:
public String getName() {
Again you will see something like this
Code:
return "Pro Fisher";
So the script can be found in the Fishing category and is called Pro Fisher.

5. How to add your bank pin to Rsbot

Firstly load up Rsbot, either Members or Non members, then go to Settings > Account manager and choose your account.

Now choose your account and in the box next to Add Key type in PIN.



Now look to the right and you will see a column saying value, click it and type in your pin then hit enter.



Next click Apply, Then Okay and you're done.

---------------------------------------------------------------------------------------------------

This guide isn't mine and I didn't make it. The original maker is Karl. ALL credits go to him. only credits for me is for posting this and merged it together. still not working? feel free to ask 

How to make a timer without being an idiot

1 comments

If you do not have a basic understanding of Java, this tutorial is not for you. Some programming knowledge and object-oriented concepts are required. Very trivial things are left unexplained.

You will need the following imports:

Code: [Select]
import java.util.Timer;
import java.util.TimerTask;

Or just import the whole util package.

The Timer class allows you to do two important things:
  • Set up a task to run at some point in the future
  • Set up a task to repeat at a certain interval (e.g. every 500 milliseconds)

The idiom is to first instantiate a Timer and then schedule TimerTasks to be run by the timer according to certain rules.
Code: [Select]
Timer timer = new Timer();
The timer's schedule method is used to preform both of the functions listed above. Here are the method signatures with descriptions (taken straight from the API):
Code: [Select]
void        schedule(TimerTask task, Date time)
          Schedules the specified task for execution at the specified time.
 void        schedule(TimerTask task, Date firstTime, long period)
          Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.
 void        schedule(TimerTask task, long delay)
          Schedules the specified task for execution after the specified delay.
 void        schedule(TimerTask task, long delay, long period)
          Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.

I will demonstrate the third and fourth (the first and second are just the same, except instead of taking a number of milliseconds to wait, they take a Date in the future at which to begin running).

Code: [Select]
        public static void demoDelayedTask() {
                Timer timer = new Timer();
                int delayTime = 2000; // Milliseconds to wait before running delayed task
               
                timer.schedule(new TimerTask() {
                        @Override
                        public void run() {
                                System.out.println("Delayed task has been run.");
                                System.out.println("Current time: " + System.currentTimeMillis());
                        }                       
                }, delayTime);
        }

Here I declare the TimerTask as an anonymous class. You can also do something like
Code: [Select]
TimerTask task = new TimerTask() {...};if it's more convenient.

The following code is similar, except it schedules a timer to be run multiple times:
Code: [Select]
        public static void demoRepeatingTask() {
                Timer timer = new Timer();
                int delayTime = 3000; // Time to wait before starting the timer
                int repeatInterval = 300; // Time to wait between runs
               
                timer.schedule(new TimerTask() {
                        int timesRun;

                        @Override
                        public void run() {
                                timesRun++;
                                System.out.println("Repeating task run " + timesRun + " times.");
                                printTime();
                               
                                if(timesRun >= 10) {
                                        System.out.println("Run 10 times, it's time to stop!");
                                        cancel();
                                }
                        }
                }, delayTime, repeatInterval);
        }

Note that the cancel() called here if called on the TimerTask and not the Timer. This will cancel only that particular task. Timer also has a method called cancel() which cancels all TimerTasks bound to a timer.

To achieve the same result using the methods taking dates, just pass in a Date:
Code: [Select]
Date dateToRun = new Date(System.currentTimeMillis() + timeToWait);is an example of a date to pass. The date replaces the delay time.The other fields are the same. Using Dates is useful for stuff like scheduling something in hours/days/months using GregorianCalendar rather than something in the near future using milliseconds.

There are also these methods to schedule on Timers:
Code: [Select]
void        scheduleAtFixedRate(TimerTask task, Date firstTime, long period)
          Schedules the specified task for repeated fixed-rate execution, beginning at the specified time.
 void        scheduleAtFixedRate(TimerTask task, long delay, long period)
          Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.

These act exactly like the other method using delay and repeat interval, but will change the repeat interval to compensate for lost time.

For example, if garbage collecting locks up the computer for 200 ms, and the task is set to run every 1000 ms, it will wait less than 1000 ms so that the task always runs at the same interval rather than with the same wait. If you've ever looked at an old server source in server.java, this is the same general concept with subtracting processing time from the cycling time.

Here is a demo class to play with:
Code: [Select]
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author Aftermath
 * Demonstrates scheduling a task to run in the future.
 */
public class TimerDemo {
        public static void main(String... args) throws Exception {
                System.out.println("Starting Timer demo.");
                printTime();
               
                System.out.println("Demonstrating delayed task: ");
                demoDelayedTask();
               
                // Timer tasks are kept track of in separate threads.
                // Without this line the other timer would begin and
                // the output would overlap. This is just for display purposes.
                Thread.sleep(5000);
               
                System.out.println("Demonstrating delayed repeating task: ");
                demoRepeatingTask();
        }
       
        /**
         * Schedules a task to run in a certain period of time.
         */
        public static void demoDelayedTask() {
                Timer timer = new Timer();
                int delayTime = 2000; // Milliseconds to wait before running delayed task
               
                timer.schedule(new TimerTask() {
                        @Override
                        public void run() {
                                System.out.println("Delayed task has been run.");
                                System.out.println("Current time: " + System.currentTimeMillis());
                        }                       
                }, delayTime);
        }
       
        /**
         * Schedules a repeating task to begin in a certain period of time.
         * Also demonstrates how to stop a task after a certain number of runs.
         */
        public static void demoRepeatingTask() {
                Timer timer = new Timer();
                int delayTime = 3000; // Time to wait before starting the timer
                int repeatInterval = 300; // Time to wait between runs
               
                timer.schedule(new TimerTask() {
                        int timesRun;

                        @Override
                        public void run() {
                                timesRun++;
                                System.out.println("Repeating task run " + timesRun + " times.");
                                printTime();
                               
                                if(timesRun >= 10) {
                                        System.out.println("Run 10 times, it's time to stop!");
                                        cancel();
                                }
                        }
                }, delayTime, repeatInterval);
        }
       
        //
       
        public static void printTime() {
                System.out.println("Current time: " + System.currentTimeMillis());
        }
}

And sample output:
Code: [Select]
Starting Timer demo.
Current time: 1290055585097
Demonstrating delayed task:
Delayed task has been run.
Current time: 1290055587099
Demonstrating delayed repeating task:
Repeating task run 1 times.
Current time: 1290055593099
Repeating task run 2 times.
Current time: 1290055593399
Repeating task run 3 times.
Current time: 1290055593699
Repeating task run 4 times.
Current time: 1290055593999
Repeating task run 5 times.
Current time: 1290055594299
Repeating task run 6 times.
Current time: 1290055594599
Repeating task run 7 times.
Current time: 1290055594899
Repeating task run 8 times.
Current time: 1290055595199
Repeating task run 9 times.
Current time: 1290055595499
Repeating task run 10 times.
Current time: 1290055595799
Run 10 times, it's time to stop!

P.S.: you can also add ActionListeners to timers and they will trigger whenever tasks are executed. If you use anonymous classes be careful of the scope - only final variables can be accessed. It's better to just use method calls.

Time and Date

0 comments

The handler:

Class for getting time and date.

The documentation explains it, that's why its in the tutorial section.

I already know theres shorter ways of doing this, but I honestly don't give a shit.

Code: [Select]
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * Gets the time and date.
 *
 * @author Ryan Greene
 *
 */
public class Time {

        /**
         * Instance for the time.
         */
        private static Time time = new Time();

        /**
         * Gets the time.
         *
         * @return The time.
         */
        public static Time getTime() {
                return time;
        }

        /**
         * Instance for the calendar.
         */
        Calendar cal = new GregorianCalendar();

        /**
         * The day.
         */
        private int day = cal.get(Calendar.DAY_OF_MONTH);

        /**
         * The month.
         */
        private int month = cal.get(Calendar.MONTH);

        /**
         * The year.
         */
        private int year = cal.get(Calendar.YEAR);

        /**
         * The hour.
         */
        private int hour = cal.get(Calendar.HOUR);

        /**
         * The minute.
         */
        private int min = cal.get(Calendar.MINUTE);

        /**
         * The second.
         */
        private int sec = cal.get(Calendar.SECOND);

        /**
         * Gets the day.
         *
         * @return The day.
         */
        public int getDay() {
                return day;
        }

        /**
         * Gets the month.
         *
         * @return The month.
         */
        public int getMonth() {
                return month;
        }

        /**
         * Gets the year.
         *
         * @return The the year.
         */
        public int getYear() {
                return year;
        }

        /**
         * Gets the hour.
         *
         * @return The hour.
         */
        public int getHour() {
                return hour;
        }

        /**
         * Gets the minute.
         *
         * @return The minute.
         */
        public int getMin() {
                return min;
        }

        /**
         * Gets the second.
         *
         * @return The second.
         */
        public int getSec() {
                return sec;
        }

        /**
         * Holds the month names.
         */
        private String[] monthNames = { "January", "Febuary", "March", "April",
                        "May", "June", "July", "Augest", "September", "October",
                        "November", "December" };

        /**
         * Gets the month name.
         *
         * @return The month name.
         */
        public String getMonthName() {
                return monthNames[getMonth()];
        }
}

Example on how to use this:
Code: [Select]
                logger.info("Year: " + Time.getTime().getYear() + " Month: "
                                + Time.getTime().getMonth() + " Day: "
                                + Time.getTime().getDay() + " Hour: "
                                + Time.getTime().getHour() + " Minute: "
                                + Time.getTime().getMin() + " Month name: "
                                + Time.getTime().getMonthName());

Examples of way to use this in a RSPS:

Using my dialogue handler witch can be found at the end of the tutorial:

Replace dialogueData with this:
Code: [Select]
        /**
         * Array to store dialogue data. <next dialgouge ID, head animation ID, type
         * of dialogue, dialogue text>.
         */
        private static Object[][] dialogueData = {
                        { 1, 591, "NPC", "Good day, how can I help you?" },
                        { -1, -1, "OPTION", "I'd like to access my bank account, please.",
                                        "I'd like to check my PIN settings." },
                        { -1, 591, "PLAYER", "I'd like to access my bank account, please." },
                        { -1, 591, "PLAYER", "I'd like to check my PIN settings." },
                        { 5, 591, "NPC", "Oy matey! What would you like to do?" },
                        { -1, 591, "OPTION", "I'd like to do fishing trawler.",
                                        "I'd like to ride your boat." }, // 5
                        { -1, 591, "NPC", "Argh, I'm sorry matey.",
                                        "That minigame is still under construction!" },
                        { -1, 591, "NPC", "Oy, and where would you like to go?" },
                        { -1, 591, "NPC", "Hello, I can take you in my wheel barrow",
                                        "to various places.", "Where would you like to go?" },
                        { 10, 591, "NPC", "Hello, what would you like to do?" },
                        { -1, 591, "OPTION", "View server time.", "Nevermind." },
                        { 10, 591, "NPC", "Sure! It is currently: " + Time.getTime().getHour() + ":"
                                        + Time.getTime().getMin() }
        };
Replace handleOptions with this:

Code: [Select]
        /**
         * Handles dialogue options.
         *
         * @param player
         *            The player.
         * @param actionButton
         *            The action button.
         */
        public static void handleOptions(Player player, int actionButton) {
                int d = player.getDialogueId();
                if (actionButton == 2461) { // 1 2
                        switch (d) {
                        case 1:
                                sendDialogue(player, 2);
                                break;
                        case 5:
                                sendDialogue(player, 6);
                                break;
                        case 10:
                                sendDialogue(player, 11);
                        default:
                                player.getInterfaceState().interfaceClosed();
                                break;
                        }
                } else if (actionButton == 2462) { // 2 2
                        switch (d) {
                        case 1:
                                sendDialogue(player, 3);
                                break;
                        case 5:
                                sendDialogue(player, 7);
                                break;
                        default:
                                player.getInterfaceState().interfaceClosed();
                                break;
                        }
                }
        }

Using JScript

0 comments

In this short tutorial I will teach you how to use Hyperion's JScript engine (And if you don't use Hyperion how to implant it).

If you do not use Hyperion, add this in your server:

Code: [Select]
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * Manages server scripts.
 *
 * @author blakeman8192
 *
 */
public class ScriptManager {

        /**
         * The singleton of this class.
         */
        private static final ScriptManager INSTANCE = new ScriptManager();

        /**
         * Gets the ScriptManager singleton.
         *
         * @return The ScriptManager singleton.
         */
        public static ScriptManager getScriptManager() {
                return INSTANCE;
        }

        /**
         * The ScriptEngineManager.
         */
        private ScriptEngineManager mgr;

        /**
         * The JavaScript Engine.
         */
        private ScriptEngine jsEngine;

        /**
         * The logger for this manager.
         */
        private final Logger logger = Logger.getLogger(this.toString());

        /**
         * Creates the script manager.
         */
        private ScriptManager() {
                mgr = new ScriptEngineManager();
                jsEngine = mgr.getEngineByName("JavaScript");
                logger.info("Loading scripts...");
        }

        /**
         * Invokes a JavaScript function.
         *
         * @param identifier
         *            The identifier of the function.
         * @param args
         *            The function arguments.
         */
        public void invoke(String identifier, Object... args) {
                Invocable invEngine = (Invocable) jsEngine;
                try {
                        invEngine.invokeFunction(identifier, args);
                } catch (NoSuchMethodException ex) {
                        logger.log(Level.WARNING, "No such method: " + identifier);
                } catch (ScriptException ex) {
                        logger.log(Level.WARNING, "ScriptException thrown!", ex);
                }
        }

        /**
         * Loads JavaScript files into the JavaScript ScriptEngine from the argued
         * path.
         *
         * @param dirPath
         *            The path of the directory to load the JavaScript source files
         *            from.
         */
        public void loadScripts(String dirPath) {
                File dir = new File(dirPath);
                if (dir.exists() && dir.isDirectory()) {
                        File[] children = dir.listFiles();
                        for (File child : children) {
                                if (child.isFile() && child.getName().endsWith(".js"))
                                        try {
                                                jsEngine.eval(new InputStreamReader(
                                                                new FileInputStream(child)));
                                        } catch (ScriptException ex) {
                                                logger.log(Level.SEVERE, "Unable to load script!", ex);
                                        } catch (FileNotFoundException ex) {
                                                logger.log(Level.SEVERE, "Unable to find script!", ex);
                                        }
                                else if (child.isDirectory())
                                        loadScripts(child.getPath());
                        }
                }
                logger.info("Loaded scripts!");
        }

}

Also if you don't use Hyperion, add this where your server startup is done:
Code: [Select]
ScriptManager.getScriptManager().loadScripts("data/scripts/");
(data/scripts/ is the path where you scripts are being held.)

In this tutorial Ill commands as an example.

In your command packet add:

Code: [Select]
ScriptManager.getScriptManager().invoke(command, (Object) args, player);
Now, look at this part of the code:

Code: [Select]
(command, (Object) args, player)
The string command is the name of the method that the script manager will call. (example: if you're command name is "pos", the script manager will look for a method named pos.)

The string args and the instance player is looked for in "( )" after the method name.
Example, using the command pos again:

Code: [Select]
function pos(args,player) {
        player.getActionSender().sendMessage("You are at: " + player.getLocation() + ".");
}

As you see in that example, JScript is very similar to Java. Think of "function" to be "void" like in Java.

For some commands, you will need to import packages or classes. This is done fairly similar as its done in Java.

Code: [Select]
function bank(args,player) {
        Bank.open(player);
}

For that command, I need the class bank. To import that class, I have two options.

A:
I can import just that class:

Code: [Select]
importClass(org.hyperion.rs2.model.container.Bank)
Or B:
I can import the whole package. I only recommend this if you need two or more classes in that same package.

Code: [Select]
importPackage(org.hyperion.rs2.model.container)
You can do almost anything you can do in Java in JScript. Loops, arrays, switch statements. You can even import packages and classes in the Java API!

An important difference between Java and JScript is how you declare integers. Instead of doing:

Code: [Select]
int maxAmount = Integer.MAX_VALUE;
You would do:

Code: [Select]
var maxAmount = Integer.MAX_VALUE;
This is the extreme basics and how to just set it up, Ill update this tutorial again .

Christmas crackers

0 comments

This is made for Hyperion but can easily be converted.

Handles the item on player packet + Christmas crackers. Don't tell me it automatically gives the party hat to the player who pulled the cracker, I know that. It use to be this way until RWT turned into a big problem on RuneScape, but I don't think people who have a RSPS server give a shit about that.

In the stackable item array, so far it only contains money and rune arrows.
The misc item array only contains rune armor.

My documentation explains the code.

In your content folder make a new class called ChristmasCracker and add this in it:

Code: [Select]
package org.hyperion.rs2.model.content;

import org.hyperion.rs2.model.Item;
import org.hyperion.rs2.model.Player;

/**
 * Handles Christmas crackers.
 *
 * @author Ryan Greene
 *
 */
public class ChristmasCracker {

        /**
         * The array storing part hat ID's.
         */
        private static final short[] PARTY_HATS = { 1038, 1040, 1042, 1044, 1046,
                        1048 };

        /**
         * Stackable item rewards like coins.
         */
        private static final short[][] STACKABLE_ITEMS = {
                        { 995, generateRandomNumber(50000) },
                        { 892, generateRandomNumber(500) } };

        /**
         * Misc item rewards like armor.
         */
        private static final short[] MISC_ITEMS = { 1079, 1093, 1127, 1163, 1201 };

        /**
         * The cracker ID.
         */
        private static final short CRACKER_ID = 962;

        /**
         * The player that didn't win the party hat.
         */
        Player loser;

        /**
         * Pulls the Christmas cracker and gives the rewards.
         *
         * @param puller
         *            The player that pulled the cracker.
         * @param target
         *            The player that the cracker was used on.
         */
        public static void pullCracker(Player puller, Player target) {
                if (target.getInventory().freeSlots() <= 2) {
                        puller.getActionSender().sendMessage(
                                        "Your target doesn't have enough inventory space!");
                        return;
                }
                if (puller.getInventory().freeSlots() <= 2) {
                        puller.getActionSender().sendMessage(
                                        "You don't have enough inventory space!");
                        return;
                }
                Player winner = generateRandomNumber(1) == 0 ? puller : target;
                Player loser = winner == puller ? target : puller;

                int partyHat = generateRandomNumber(PARTY_HATS.length);
                int stackableItem = generateRandomNumber(STACKABLE_ITEMS.length);
                int miscItem = generateRandomNumber(MISC_ITEMS.length);

                puller.getInventory().remove(new Item(CRACKER_ID));
                winner.getInventory().add(new Item(PARTY_HATS[partyHat]));
                loser.getInventory().add(
                                new Item(STACKABLE_ITEMS[stackableItem][0],
                                                STACKABLE_ITEMS[stackableItem][1]));
                loser.getInventory().add(new Item(MISC_ITEMS[miscItem]));

                winner.getActionSender().sendMessage(
                                "Congrats! You have won the party hat!");
                loser.getActionSender().sendMessage(
                                "Drats! You didn't win the party hat!");
        }

        /**
         * Generates a random number.
         *
         * @param number
         *            Generates a number between 0 and (number).
         * @return The generated number.
         */
        private static short generateRandomNumber(int number) {
                return (short) new java.util.Random().nextInt(number + 1);
        }
}

In your packet package make a new class called ItemOnItemPacketHandler and add this in it:

Code: [Select]
package org.hyperion.rs2.packet;

import org.hyperion.rs2.model.Player;
import org.hyperion.rs2.model.World;
import org.hyperion.rs2.model.content.ChristmasCracker;
import org.hyperion.rs2.net.Packet;

/**
 * Handles the item on player packet.
 *
 * @author Ryan Greene
 *
 */
public class ItemOnPlayerPacketHandler implements PacketHandler {

        @Override
        public void handle(Player player, Packet packet) {
                @SuppressWarnings("unused")
                final int playerIndex = packet.getShortA();
                final int playerId = packet.getShort();
                final int itemId = packet.getShort();
                @SuppressWarnings("unused")
                final int itemSlot = packet.getLEShortA();
                final Player target = (Player) World.getWorld().getPlayers().get(
                                playerId);
                if (itemId == 962) {
                        ChristmasCracker.pullCracker(player, target);
                }
        }
}

In your configuration file in your data folder add this:

Code: [Select]
#    item used on a player
packetHandlers[14]: org.hyperion.rs2.packet.ItemOnPlayerPacketHandler

The reason the puller and the target need at least two inventory space is because the loser will receive two items.

Removing an admins ability to transfer items [BattleScape]

0 comments

First off, I am Jeff from R-S. I did not 'leech' these. I am simply sharing with you guys since I am back now. I wrote these myself, no tutorials were involved.

Alright, well I thought this could be useful.

I know this has been posted before, but not for BattleScape.


What this does:
-Administrators cannot drop items
-Administrators can duel, but they cannot stake
-Administrators cannot trade with other players
-Administrators don't lose items upon death.

I did it this way so your players can still fight with admins in mini-games, or fun fights in the wilderness.

Difficulty - 0/1

Assumed knowledge - Copy and paste

Classes modified - Just your client class.


Alright, first we will disable item dropping.

in your client class search for:

Code: [Select]
public void DropItem()
Now under your ints, add this:

Code: [Select]
                if (playerRights >= 2) {
                        sendMessage("Administrators aren't able to drop items.");
                        return;
                }

What this does is it checks the players rights. If it is equal to or greater than 2, it won't complete the dropping of an item action.


Alright, next we will disable trading.

search for:

Code: [Select]
case 153:
Now under this:

Code: [Select]
                                //TradePlayer
                                TradingWith = misc.HexToInt(inStream.buffer, 0, packetSize) / 1000;
                                p = Server.s.playerHandler.clients[TradingWith];
                                TurnPlayerTo(32768 + TradingWith);


Add this:


Code: [Select]
if (playerRights > 1 && p.playerRights < 2 || playerRights < 2 && p.playerRights > 1) {
        sendMessage("Administrators cannot trade other players.");
        return;
}

This will completely disable trading for administrators. However it will give admins the ability to trade other admins.



Alright, next we will disable the ability for administrators to lose items upon death.


search for:

Code: [Select]
public void ApplyDead()
In that void, add this:

Code: [Select]
if (playerRights >= 2) {
                resetDamage();
                deadTele();
                IsDead = false;
                killMyNPCs();
                resetDuel();
                resetEmotes();
                resetKeepItem();
                resetOtherAtk();
                setSkillLevel(i);
                updateHp(getLevelForXP(playerXP[3]), true);
                knightWavesGame = 0;
                playerUpdate();
                specialAmount = 100;
                sendMessage("Since you're an administrator, you do not lose items");
                return;
}


Alright, next we will remove their abilities to stake items in a duel.

Search for:

Code: [Select]
public boolean stakeItem(int itemId, int itemSlot, int itemAmount)
Right under that boolean add this:


Code: [Select]
        if (playerRights >= 2) {
                sendMessage("Administators aren't aloud to stake in a duel");
                return true;
        }

That will disable administrators ability to stake.


Save compile, and bam. Your economy is safe from reckless administrators.