Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.RSCharacter;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = "Felten De Meulenaere", name = "RemoteControl", version = 1.0)
- public class RemoteControl extends Script{
- @Override
- public int loop() {
- remoteControl rc = new remoteControl();
- rc.commands("blow meh nao");
- return 1000;
- }
- public class remoteControl {
- private void commands(String sender) {
- String pm = interfaces.get(754).getComponent(5).getText().toLowerCase();
- String getSender = pm.substring(3, pm.indexOf(":"));
- String getCommand = pm.substring(pm.indexOf(":")+2);
- if(getSender.equals(sender.toLowerCase())) {
- if(getCommand.equals("::stop")) {
- sendPrivateMessage(sender, "Stopping...");
- stopScript();
- }
- if(getCommand.startsWith("::logout")) {
- String text = getCommand.replaceAll("::logout ", "").toString();
- if(text.equals("lobby")) {
- sendPrivateMessage(sender, "Logging out to lobby");
- game.logout(true);
- }
- if(text.equals("welcomescreen")) {
- sendPrivateMessage(sender, "Logging out to welcomescreen");
- game.logout(false);
- }
- }
- if(getCommand.equals("::pause")) {
- if(!isPaused()) {
- sendPrivateMessage(sender, "Paused");
- setPaused(true);
- }
- }
- if(getCommand.equals("::getmessage")) {
- String message =game.getLastMessage().replaceAll("<col=0000ff>", "");
- if(!message.isEmpty())
- sendPrivateMessage(sender, message);
- }
- if(getCommand.startsWith("::talk")) {
- String text = getCommand.replaceAll("::talk ", "").toString();
- sendPrivateMessage(sender, "Said: " + text);
- keyboard.sendText(text, true);
- }
- if(getCommand.startsWith("::reply")) {
- String[] words = getCommand.split(" ");
- String player = words[1];
- String message = getCommand.replaceAll("::reply " + player + " ", "").toString();
- sendPrivateMessage(sender, "Replied to:" + player);
- keyboard.sendText("@" +player+ ", " + message, true);
- }
- if(getCommand.equals("::getplayers")) {
- RSPlayer player = players.getNearest(new Filter<RSPlayer>() {
- public boolean accept(RSPlayer n) {
- return !(n.getName().equals(getMyPlayer().getName()));
- }
- });
- if(player != null) {
- sendPrivateMessage(sender, "Nearest player: " + player.getName() + "");
- } else {
- sendPrivateMessage(sender, "No players nearby!");
- }
- }
- if(getCommand.equals("::gethp")) {
- int hpPercent = getMyPlayer().getHPPercent();
- int totalHp = skills.getCurrentLevel(skills.CONSTITUTION) * 10;
- int currentHp = (totalHp * 100) / hpPercent;
- sendPrivateMessage(sender, "HP: " + hpPercent + " percent, [".toString() + currentHp + "/" + totalHp + "]");
- }
- if(getCommand.equals("::getamountofplayers")) {
- RSPlayer[] player = players.getAll();
- sendPrivateMessage(sender, "There are " + player.length + " players nearby.");
- }
- if(getCommand.equals("::getlocation")) {
- int x = getMyPlayer().getLocation().getX();
- int y = getMyPlayer().getLocation().getY();
- sendPrivateMessage(sender, "Location: [" + x +", " + y +"]");
- }
- if(getCommand.equals("::getplane")) {
- int plane = game.getPlane();
- sendPrivateMessage(sender, "height: " + plane + ".");
- }
- if(getCommand.startsWith("::break")) {
- String[] words = getCommand.split(" ");
- int time = Integer.parseInt(words[1].trim()) * 1000;
- sendPrivateMessage(sender, "Taking break for " + time/1000 + " seconds.");
- sleep(time);
- }
- }
- }
- private void openTab(int tab) {
- while(game.getCurrentTab() != tab) {
- game.openTab(tab);
- sleep(300, 400);
- }
- }
- private void sendPrivateMessage(String reciever, String message) {
- openTab(game.TAB_FRIENDS);
- for(int i=0; i <= 200; i++) {
- if(interfaces.get(550).getComponent(2).getComponent(i).getText().contains(reciever)) {
- if(!interfaces.get(550).getComponent(2).getComponent(i + 2).containsText("Offline")) {
- mouse.click(interfaces.get(550).getComponent(2).getComponent(i).getLocation(), false);
- sleep(100, 200);
- menu.doAction("Message");
- sleep(300, 400);
- keyboard.sendText(message, true);
- log("Sended message: \"" + message + "\" to " + reciever +".");
- } else {
- log.warning(interfaces.get(550).getComponent(2).getComponent(i).getText() + " is offline");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment