Jump to content

Question [Noob Scripter Starting Out]


Sean

Recommended Posts

Was following this tutorial so shoutout to Apaec 

 

Bascially changing it up to make it pickpocket men in lumby.

 

Problem I'm having currently is that the script won't start when I press the play button. So it doesn't run.

 

 

Code here since people said post it tongue.png

 

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;



import java.awt.*;
import java.lang.Thread.State;

@ScriptManifest(author = "Sean", info = "My first script", name = "Man Pickpocketer", version = 0, logo = "")
public class main extends Script {

@Override
public void onStart() {
log("Welcome to my Trial Script (Thieving)");
}

private enum State {
     PICKPOCKET, WAIT;
};

private State getState(){
NPC Man = npcs.closest("Man");
if (Man != null)
return State.PICKPOCKET;
return State.WAIT;
}
@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case PICKPOCKET:
NPC Man = npcs.closest("Man");
if (Man !=null) {
Man.interact("Pickpocket");
}
break;
case WAIT:
sleep(random(400,600));
break;
}
return random(200, 300);
}

@Override
public void onExit() {
log("Thx for using this script");
}

@Override
public void onPaint(Graphics2D g) {

}

}
 
Edited by Sean001
Link to comment
Share on other sites

I'm just guessing that you dont have your ScripManifest tongue.png

@ScriptManifest ...

class test extends Script{
}

You will need to import it and add the methods. boge.png

 

And post your code, people are glad to help others, no shame in what you have. We will give you tips etc. :)

Edited by Vilius
Link to comment
Share on other sites

If you're just starting out it doesn't really matter? take priority in learning over your one day of java pride.

 

If you're starting out we expect to see faults in the code anyway.

 

 

I'm just guessing that you dont have your ScripManifest tongue.png

@ScriptManifest ...

class test extends Script{
}

You will need to import it and add the methods. boge.png

 

And post your code, people are glad to help others, no shame in what you have. We will give you tips etc. smile.png

 

 

 

Post code || make sure you have a ScriptManifest

//Example
@ScriptManifest(author = "Sinatra", name = "Trinity Dragons", info = "", logo = "http://i.imgur.com/MCq1qNX.png", version = 5.5)

posted code

Link to comment
Share on other sites

Man is a NPC not a object. NPC man = npcs.closest("man");

 

You're also missing a " after your name in the manifest.

Thank you changed that but the script still doesn't show up as a local script on the osbot client which is my main issue.

 

Edit: I see alot of red "X" by the lines of my code. Is that an issue? (assuming) 

Edited by Sean001
Link to comment
Share on other sites


import org.osbot.rs07.api.model.NPC;

import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

import java.lang.Thread.State;

@ScriptManifest(author = "Sean", info = "My first script", name = "Man Pickpocketer", version = 0, logo = "")

public class main extends Script {

@Override

public void onStart() {

log("Welcome to my Trial Script (Thieving)");

}

private enum State {

PICKPOCKET, WAIT;

};

private State getState(){

NPC Man = npcs.closest("Man");

if (Man != null)

return State.PICKPOCKET;

return State.WAIT;

}

@Override

public int onLoop() throws InterruptedException {

switch (getState()) {

case PICKPOCKET:

NPC Man = npcs.closest("Man");

if (Man !=null) {

Man.interact("Pickpocket");

}

break;

case WAIT:

sleep(random(400,600));

break;

}

return random(200, 300);

}

@Override

public void onExit() {

log("Thx for using this script");

}

@Override

public void onPaint(Graphics2D g) {

}

}

Link to comment
Share on other sites

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 


import java.awt.*;
import java.lang.Thread.State;
 
@ScriptManifest(author = "Sean", info = "My first script", name = "Man Pickpocketer", version = 0, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Welcome to my Trial Script (Thieving)");
    }

    private enum State {
    	 PICKPOCKET, WAIT;
    };
    
    private State getState(){
     NPC Man = npcs.closest("Man");
     if (Man != null)
     return State.PICKPOCKET;
     return State.WAIT;
    }
     @Override
    public int onLoop() throws InterruptedException {
     switch (getState()) {
     case PICKPOCKET:
     NPC Man = npcs.closest("Man");
     if (Man !=null) {
     Man.interact("Pickpocket");
     }
     break;
     case WAIT:
     sleep(random(400,600));
break;
    }
return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thx for using this script");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

Thx for the corrections :)

Figured out why it wasn't appearing on my scripts list so that's fixed.

 

Only problem Im having now is it won't start when I press the play button.

Link to comment
Share on other sites

Thx for the corrections smile.png

Figured out why it wasn't appearing on my scripts list so that's fixed.

 

Only problem Im having now is it won't start when I press the play button.

 

If you're looking for help then you need to start giving more specific questions. "Not starting" doesn't really help. Does the script start but it stands there and does nothing? or you cant even start it? put logs on your states and see if they log.

Edited by Shudsy
Link to comment
Share on other sites

If you're looking for help then you need to start giving more specific questions. "Not starting" doesn't really help. Does the script start but it stands there and does nothing? or you cant even start it? put logs on your states and see if they log.

When I press the play button. The script in general doesn't start so nothing happens. I don't get the stop button appearing so I can't even start it.

 

Edit: Im off pc now so any code changes will need to happen tomorrow.

Edited by Sean001
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...