Jump to content

Local script not appearing in selector / any problems with code


kingwill

Recommended Posts

Hi I am new here and trying to build my own experiments script.

When I build the jar file into the /OSBot/Scripts folder and run OSBot it does not come up in the client.

However, when the client is open and I try to delete the jar from the folder it says I cannot because it is in use.

I have copy and pasted the code to a new file but it still does not appear.

 

I am using IntelliJ to create my jar, and when I select the main class it says 'not available' but still allows me to build and reports it as successful.

 

The reason I have coded the script like this is because all AIO fighters still click the level 52 experiment, that is why I have based it on IDs not npc name, so if you think there may be issues further down the line due to this please let me know.

Cheers

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
import javax.swing.*;

@ScriptManifest(author = "The man", info = "Experimental experiment killer", name = "Experimental experiment killer", version = 0.1, logo = "")
public class ExperimentKilla extends Script {

    public static String status;

    @Override
    public void onStart() {
        JOptionPane.showMessageDialog(null, "Welcome to my first script hello world");
    }

    private enum State {
        ATTACK1, ATTACK2, WAIT
    }

    private State getState(){
        NPC experiment1 = npcs.closest(1274);
        NPC experiment2 = npcs.closest(1275);
        if (experiment1 != null){
            return State.ATTACK2;
        }
        if (experiment2 != null){
            return State.ATTACK1;
        }
        return State.WAIT;
    }

    @Override
    public int onLoop() throws InterruptedException {
        switch(getState()){
            case ATTACK1:
                NPC experiment1 = npcs.closest(1274);

                if (experiment1 != null && !combat.isFighting() && !experiment1.isUnderAttack() && experiment1.isAttackable()) {
                    experiment1.interact("Attack");
                    status = "Attacking experiment 1";
                    sleep(random(200,800));
                }
                break;
            case ATTACK2:
                NPC experiment2 = npcs.closest(1275);
                if (experiment2 != null && !combat.isFighting() && !experiment2.isUnderAttack() && experiment2.isAttackable()){
                    experiment2.interact("Attack");
                    status = "Attacking experiment 2";
                    sleep(random(200,800));
                }

                break;
            case WAIT:
                sleep(random(299, 643));
                break;
        }
        return random(100,540);
    }

    @Override
    public void onExit(){
        JOptionPane.showMessageDialog(null, "Thanks for using.");
    }

    @Override
    public void onPaint(Graphics2D g){

    }

}
Edited by kingwill
Link to comment
Share on other sites

 

Hi I am new here and trying to build my own experiments script.

When I build the jar file into the /OSBot/Scripts folder and run OSBot it does not come up in the client.

However, when the client is open and I try to delete the jar from the folder it says I cannot because it is in use.

I have copy and pasted the code to a new file but it still does not appear.

 

The reason I have coded the script like this is because all AIO fighters still click the level 52 experiment, that is why I have based it on IDs not npc name, so if you think there may be issues further down the line due to this please let me know.

Cheers

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
import javax.swing.*;

@ScriptManifest(author = "The man", info = "Experimental experiment killer", name = "Experimental experiment killer", version = 0.1, logo = "")
public class ExperimentKilla extends Script {

    public static String status;

    @Override
    public void onStart() {
        JOptionPane.showMessageDialog(null, "Welcome to my first script hello world");
    }

    private enum State {
        ATTACK1, ATTACK2, WAIT
    }

    private State getState(){
        NPC experiment1 = npcs.closest(1274);
        NPC experiment2 = npcs.closest(1275);
        if (experiment1 != null){
            return State.ATTACK2;
        }
        if (experiment2 != null){
            return State.ATTACK1;
        }
        return State.WAIT;
    }

    @Override
    public int onLoop() throws InterruptedException {
        switch(getState()){
            case ATTACK1:
                NPC experiment1 = npcs.closest(1274);

                if (experiment1 != null && !combat.isFighting() && !experiment1.isUnderAttack() && experiment1.isAttackable()) {
                    experiment1.interact("Attack");
                    status = "Attacking experiment 1";
                    sleep(random(200,800));
                }
                break;
            case ATTACK2:
                NPC experiment2 = npcs.closest(1275);
                if (experiment2 != null && !combat.isFighting() && !experiment2.isUnderAttack() && experiment2.isAttackable()){
                    experiment2.interact("Attack");
                    status = "Attacking experiment 2";
                    sleep(random(200,800));
                }

                break;
            case WAIT:
                sleep(random(299, 643));
                break;
        }
        return random(100,540);
    }

    @Override
    public void onExit(){
        JOptionPane.showMessageDialog(null, "Thanks for using.");
    }

    @Override
    public void onPaint(Graphics2D g){

    }

}

 

Try deleting the OSBot folder, restarting OSBot, and then re-building your script.

  • Like 1
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...