Jump to content

script wont launch


Recommended Posts

Posted
 
I kinda need help with a tanning script i wrote, whenever I launch it via OSbot i get a couple of error messages and since im new to this all info and help would be accepted, thanks in advance.
 
 
package tanHide;
 
import java.awt.Graphics;
 
import org.osbot.rs07.script.Script;
import org.osbot.rs07.api.Bank;
 
import org.osbot.rs07.api.Inventory;
 
import org.osbot.rs07.api.map.Area;
 
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;
 
import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(author = "Andrey", info = "Tans hides(osrs_f2p)", logo = "kek", name = "Hide_tanner", version = 0.1)
 
public class TanHide extends Script {
   //executes code
final Area BANK_AREA = new Area(3272,3173,3269,3161);
final Area TAN_AREA = new Area(3270,3189,3277,3194);
final int BANK_BOOTH_ID=396;
final int ELLIS_ID=3231;
public void onStart(){
 
 
 
}
//code executed at end
public void onExit(){
 
 
 
}
Inventory inven = client.getMethods().getInventory();
Player player = client.getMethods().myPlayer();
Bank bank = client.getMethods().getBank();
 
 
//code in loop, goes into bank, takes hide, goes to tanner and back
public int onLoop() throws InterruptedException {
//banker interaction
if(inven.isEmptyExcept(995)){
if(BANK_AREA.contains(player)){
             NPC banker = npcs.closest(BANK_BOOTH_ID);
if(bank.isOpen()){
           
             bank.withdrawAll(1739);
           
              }else{
             if(banker!=null){
             if(banker.isVisible()){
             banker.interact("Bank");
             sleep(random(700,800));
             }
           
             }
           
           
              }
 
 
}else{
 
getLocalWalker().walk(BANK_AREA,true);
 
}
 
 
}else{
//tanner interaction
getLocalWalker().walk(TAN_AREA,true);
NPC ellis = npcs.closest(ELLIS_ID);
NPC banker = npcs.closest(BANK_BOOTH_ID);
if(ellis!=null){
         if(ellis.isVisible()){
         ellis.interact("Trade");
       
        sleep(random(700,800));
        ellis.getMethods().getWidgets().getWidgetContainingText("Hard Leather").interact("All");
        getLocalWalker().walk(BANK_AREA,true);
        if(banker!=null){
         if(banker.isVisible()){
         banker.interact("Bank");
         sleep(random(700,800));
         bank.depositAllExcept(995);
         }
      }
         }
}
 
 
 
}
return 50;
}
//paint
public void onPaint(Graphics g){
 
}
}
 

 

Posted (edited)
package tanHide;

import java.awt.Graphics;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;

import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(author = "Andrey", info = "Tans hides(osrs_f2p)", logo = "kek", name = "Hide_tanner", version = 0.1)

public class TanHide extends Script {
   //executes code
	final Area BANK_AREA = new Area(3272,3173,3269,3161);
	final Area TAN_AREA = new Area(3270,3189,3277,3194);
	final int BANK_BOOTH_ID=396;
	final int ELLIS_ID=3231;
	public void onStart(){}
	//code executed at end
	public void onExit(){}
	Inventory inven = client.getMethods().getInventory();
	 Player player = client.getMethods().myPlayer();
	 Bank bank = client.getMethods().getBank();
	  
	 
	//code in loop, goes into bank, takes hide, goes to tanner and back
	public int onLoop() throws InterruptedException {
		//banker interaction
		if(inven.isEmptyExcept(995)){
			if(BANK_AREA.contains(player)){
				NPC banker = npcs.closest(BANK_BOOTH_ID);
				if(bank.isOpen()){
            	                bank.withdrawAll(1739);
            	  }else{
            		  if(banker!=null){
            			  if(banker.isVisible()){
            				  banker.interact("Bank");
            				  sleep(random(700,800));
            			  }
            		  
            		  }
            	  
            	  
            	  }
				
				
			 }else{
				 getLocalWalker().walk(BANK_AREA,true);
			 }
			
			
		}else{
			//tanner interaction
			getLocalWalker().walk(TAN_AREA,true);
			NPC ellis = npcs.closest(ELLIS_ID);
			NPC banker = npcs.closest(BANK_BOOTH_ID);
			if(ellis!=null){
       		 	if(ellis.isVisible()){
       		 		ellis.interact("Trade");
       		        sleep(random(700,800));
       		        ellis.getMethods().getWidgets().getWidgetContainingText("Hard Leather").in  teract("All");
       		        getLocalWalker().walk(BANK_AREA,true);
       		        if(banker!=null){
       		        	if(banker.isVisible()){
       		        		banker.interact("Bank");
       		        		sleep(random(700,800));
       		        		bank.depositAllExcept(995);
       		        	}
       		        }
       		  }
		    }
	  	
		
		
		}
		return 50;
	}
	//paint
	public void onPaint(Graphics g){
		
	}
}

Would this help?

 

Edited by MightySir2
Posted (edited)

I don't even know where to start tongue.png

Well... first of all, this:

Inventory inven = client.getMethods().getInventory();
Player player = client.getMethods().myPlayer();
Bank bank = client.getMethods().getBank();

What are you trying to do here? You already have access to the inventory by calling, for example, inventory.contains() directly. Same for player and bank. The reason the script doesn't start is that client doesn't exist yet, any initialization should be done in onStart. 
 

if(inven.isEmptyExcept(995)){

Should just use inventory.isEmptyExcept(995).
 

if(BANK_AREA.contains(player)){

You have access to the local player through myplayer()

 

ellis.getMethods().getWidgets().getWidgetContainingText("Hard Leather").in  teract("All");

All methods are already accessible from the script itself. You can directly call :
 

getWidgets().getWidgetContainingText("Hard Leather").interact("All");

Also, banking can simply be done by calling bank.open(), you don't have to do there interaction yourself wink.png

Edited by Flamezzz
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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