Jump to content

Mule script not wroking


Nor3g

Recommended Posts

import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "muler", author = "Nor3g", version = 1.0, info = "muler", logo = "")

public class Muler extends Script {

    String thebot = getParameters();
    String thebotrep = thebot.replace(' ', '\u00A0');

    @Override
    public void onStart() {
        //Code here will execute before the loop is started
    }
    @Override
    public void onExit() {
        System.exit(0);
        //Code here will execute after the script ends
    }
    @Override
    public int onLoop() throws InterruptedException {
        if (!Banks.VARROCK_WEST.contains(myPosition())) {
            getWalking().webWalk(Banks.VARROCK_WEST);
        } else if (Banks.VARROCK_WEST.contains(myPosition()) && getPlayers().closest(thebotrep) != null) {
            getPlayers().closest(thebotrep).interact("Trade with");
            sleep(random(450, 5000));
        } else if (!trade.getOtherPlayer().equals(thebotrep)) {
            trade.declineTrade();
            sleep(random(450, 5000));
        } else if (!trade.getTheirOffers().contains("Coins")) {
            sleep(random(450, 5000));
        } else if (trade.getTheirOffers().contains("Coins")) {
            trade.acceptTrade();
            sleep(random(450, 5000));
        } else if (trade.isSecondInterfaceOpen()) {
            if (!trade.acceptTrade()) {
                trade.acceptTrade();
                sleep(random(450, 5000));
            }
        }
        return 100; //The amount of time in milliseconds before the loop starts over
    }

    public void onMessage(Message message) {
        if (message.getMessage().contains("Accepted trade.")) {
            stop();
        }

    }
}

 

Im trying to test out my Mulescript, but it won't start. I tried to run it with this CLI command:

java -jar "osbot 2.5.38.jar" -login Nor3g:password -bot name:pass:1234 -script muler:thebot

Or more correctly, it's a bat file that is in the same folder that the osbot client is.

The client launches, however the bot doesn't start, or maybe it does. I can't click on anything within the game, yet the option to pause/stop is grayed out and unclickable.

 

It's the same error if I start the client manually and select the script to be ran manually. It won't even start the login randomsolver.

 

Any help is very much appreciated! :)

Link to comment
Share on other sites

18 minutes ago, d0zza said:

Move these lines:
 


    String thebot = getParameters();
    String thebotrep = thebot.replace(' ', '\u00A0');

 

to your onStart

I get a nullpointer exception here at the else if line:

        } else if (!trade.getOtherPlayer().equals(thebotrep)) {
            trade.declineTrade();
            sleep(random(450, 5000));

and i tried to log what thebot and thebotrep came out as, and they came out as 31, the first number in the parameter, say it should be "31 botter"

Edited by Nor3g
Link to comment
Share on other sites

1 hour ago, Nor3g said:

import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "muler", author = "Nor3g", version = 1.0, info = "muler", logo = "")

public class Muler extends Script {

    String thebot = getParameters();
    String thebotrep = thebot.replace(' ', '\u00A0');

    @Override
    public void onStart() {
        //Code here will execute before the loop is started
    }
    @Override
    public void onExit() {
        System.exit(0);
        //Code here will execute after the script ends
    }
    @Override
    public int onLoop() throws InterruptedException {
        if (!Banks.VARROCK_WEST.contains(myPosition())) {
            getWalking().webWalk(Banks.VARROCK_WEST);
        } else if (Banks.VARROCK_WEST.contains(myPosition()) && getPlayers().closest(thebotrep) != null) {
            getPlayers().closest(thebotrep).interact("Trade with");
            sleep(random(450, 5000));
        } else if (!trade.getOtherPlayer().equals(thebotrep)) {
            trade.declineTrade();
            sleep(random(450, 5000));
        } else if (!trade.getTheirOffers().contains("Coins")) {
            sleep(random(450, 5000));
        } else if (trade.getTheirOffers().contains("Coins")) {
            trade.acceptTrade();
            sleep(random(450, 5000));
        } else if (trade.isSecondInterfaceOpen()) {
            if (!trade.acceptTrade()) {
                trade.acceptTrade();
                sleep(random(450, 5000));
            }
        }
        return 100; //The amount of time in milliseconds before the loop starts over
    }

    public void onMessage(Message message) {
        if (message.getMessage().contains("Accepted trade.")) {
            stop();
        }

    }
}

 

Im trying to test out my Mulescript, but it won't start. I tried to run it with this CLI command:


java -jar "osbot 2.5.38.jar" -login Nor3g:password -bot name:pass:1234 -script muler:thebot

Or more correctly, it's a bat file that is in the same folder that the osbot client is.

The client launches, however the bot doesn't start, or maybe it does. I can't click on anything within the game, yet the option to pause/stop is grayed out and unclickable.

 

It's the same error if I start the client manually and select the script to be ran manually. It won't even start the login randomsolver.

 

Any help is very much appreciated! :)

public class Muler extends Script {

    String thebot = getParameters();
    String thebotrep;

    @Override
    public void onStart() {
    	thebotrep = thebot.replace(' ', '\u00A0');
    }

This will work

Edited by Iwin
  • Like 1
Link to comment
Share on other sites

44 minutes ago, Iwin said:

This will work

Yes it does thank you, I've fixed it.
Only problem now is the bot stops at the second trade interface and does absolutely nothing.

else if (trade.isSecondInterfaceOpen()) {
                trade.acceptTrade();
                sleep(random(450, 5000));
        }

Im absolutely clueless as to how I'm going to fix this, all help is greatly appreciated! :)

Link to comment
Share on other sites

Move that up to be the first if statement, and see what happens!

Heres a good old spoon feed of how I would do it.

Please ask whats going on so you understand! :) GL HF

if (!trade.isCurrentlyTrading()) { // Get into trading
  
  if (!Banks.VARROCK_WEST.contains(myPosition())) { // Walk to bank if we are not there
    getWalking().webWalk(Banks.VARROCK_WEST);
  }
  
  if (Banks.VARROCK_WEST.contains(myPosition()) && getPlayers().closest(thebotrep) != null) {
    if (!getPlayers().closest(thebotrep).interact("Trade with")) // Trying to trade
  		return random(450, 5000); // Trade interaction failed, returning to reset and skip everything below
    new ConditionalSleep(15000) { // Waiting 15 sec or until we have started trading
      @Override
      public boolean condition() throws InterruptedException {
        return trade.isCurrentlyTrading();
      }
    }.sleep();
    if (!trade.isCurrentlyTrading()) // Trading window not open yet!
  		return random(450, 5000); // Returning to reset and skip everything below
  }
  
}

if (!trade.getOtherPlayer().equals(thebotrep)) { // Making sure we only trade out bot
  trade.declineTrade();
  return random(450, 5000); // Returning to reset and skip everything below
}

if (!trade.isSecondInterfaceOpen() && trade.getTheirOffers().contains("Coins")) { // Waiting for coins
  trade.acceptTrade();
  new ConditionalSleep(15000) { // Wait 15 sec or until we get to the second trade interface
    @Override
      public boolean condition() throws InterruptedException {
      return trade.isSecondInterfaceOpen();
    }
  }.sleep();
}

if (trade.isSecondInterfaceOpen()) { // Accept if we are on second trade interface
  trade.acceptTrade();
}

NOT TESTED!

Edited by ItPoke
Spoon feeding
Link to comment
Share on other sites

17 hours ago, Nor3g said:

I get a nullpointer exception here at the else if line:


        } else if (!trade.getOtherPlayer().equals(thebotrep)) {
            trade.declineTrade();
            sleep(random(450, 5000));

and i tried to log what thebot and thebotrep came out as, and they came out as 31, the first number in the parameter, say it should be "31 botter"

That's because when launching through CLI the space in "31 botter" indicates that the next argument has begun.

Instead use this CLI param to run the script:
-script muler:31-botter


Then in your onstart do

    String thebot = getParameters();
    String thebotrep = thebot.replace('-', '\u00A0');
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...