Jump to content

Undefined i need help


Recommended Posts

Posted (edited)

hello im trying to make my first script just for WC so im making it to see if my inventory is full so it can go bank but it keeps telling me that "The method Inventroy() is undefined for the type Client" im not sure what i need to fix i have already imported inventory.

 

type inventory.

 

so the code will be: if(inventory.isFull())

 

Other example:

bank.open(); // open the bank

bank.isOpen() // to see if its open or not

bank.close

if(inventory.contains("Logs"))

inventory.isEmpty()

 

objects.closest("Tree").interact("Chop-down");

 

walking.walk(x, y)

 

 

Also make sure where it says:

 

public class NAME {

 

change it to

 

public class NAME extends Script {

Edited by MegaManAlpha
Posted

type inventory.

 

so the code will be: if(inventory.isFull())

 

Other example:

bank.open(); // open the bank

bank.isOpen() // to see if its open or not

bank.close

if(inventory.contains("Logs"))

inventory.isEmpty()

 

objects.closest("Tree").interact("Chop-down");

 

walking.walk(x, y)

 

 

Also make sure where it says:

 

public class NAME {

 

change it to

 

public class NAME extends Script {

here is what i have so far.

package Woodcutter;
 
import java.awt.Graphics;
 
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
@ScriptManifest(author = "", info = "", logo = "", name = "Woodcutter", version = 0.1)
public class Woodcutter extends Script{
 
 
public void onStart(){
 
}
 
 
//Code to be Excecuted at the end
public void onExit(){
 
 } //Code to loop the Seconds
public int onLoop(){
 
Inventory inven = client.getInventroy();
 
if(!inven.isFull()){
 
 
 
 
}else {
}
 
 
 
return 50;
}
//Paint
public void onPaint(Graphics g){
 
}
}
but like i said the inventory needs to be defined in a form i think or it tells me to add a cast to it.
Posted

 

here is what i have so far.

package Woodcutter;
 
import java.awt.Graphics;
 
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
@ScriptManifest(author = "", info = "", logo = "", name = "Woodcutter", version = 0.1)
public class Woodcutter extends Script{
 
 
public void onStart(){
 
}
 
 
//Code to be Excecuted at the end
public void onExit(){
 
 } //Code to loop the Seconds
public int onLoop(){
 
Inventory inven = client.getInventroy();
 
if(!inven.isFull()){
 
 
 
 
}else {
}
 
 
 
return 50;
}
//Paint
public void onPaint(Graphics g){
 
}
}
but like i said the inventory needs to be defined in a form i think or it tells me to add a cast to it.

 

 

remove the inventory invent .....

 

just put the if (getInventory().isFull) {

Posted

I already told you.

 

Where it says in your code:

Inventory inven = client.getInventroy();
 
if(!inven.isFull()){

 

put instead:

if(!inventory.isFull()){

 

 

Do not try to create an Inventory inven object, remove that line.

 

 

1) Remove that line

2) change !inven to !inventory

oh okay i get it thank you. and i apologize i didnt get what u were trying to say the first time.

Posted (edited)

oh okay i get it thank you. and i apologize i didnt get what u were trying to say the first time.

 

It's ok. I will be online on the OSBot Chat Box tomorrow if you need more help, it should be easier than making a thread.

 

Also try typing:

this.

 

when you type this.  your software will list all the options to choose from like: inventory, bank, etc. Its useful.

Edited by MegaManAlpha
Posted

remove the inventory invent .....

 

just put the if (getInventory().isFull) {

 

I already told you.

 

Where it says in your code:

Inventory inven = client.getInventroy();
 
if(!inven.isFull()){

 

put instead:

if(!inventory.isFull()){

 

 

Do not try to create an Inventory inven object, remove that line.

 

 

1) Remove that line

2) change !inven to !inventory

 

It's ugly, but it makes no difference. What he's doing is the exact same thing, so this is not the cause of error.

@OP have you imported the latest client library in your project?

  • Like 1
Posted (edited)

It's ugly, but it makes no difference. What he's doing is the exact same thing, so this is not the cause of error.

@OP have you imported the latest client library in your project?

 

FrostBug you are getting hung up on the: inventory vs getInventory()

 

The OP was not doing that. Check the source code he provided (all of it)

 

He was trying to instantiate a new Inventory object. I told him to scrap that, and just call the already declared inventory object, available via 2 methods: .inventory   or  .getInventory()   either of those replacements would have fixed his error

 

His issue has already been resolved.

Edited by MegaManAlpha
Posted

FrostBug you are getting hung up on the: inventory vs getInventory()

 

The OP was not doing that. Check the source code he provided (all of it)

 

He was trying to instantiate a new Inventory object. I told him to scrap that, and just call the already declared inventory object, available via 2 methods: .inventory   or  .getInventory()   either of those replacements would have fixed his error

 

His issue has already been resolved.

 

Inventory inven = client.getInventroy();

^

This does not create a new inventory object, but a new reference to the same object. It will work just as well as inventory or getInventory(). Despite being pointless.

 

Posted (edited)

Inventory inven = client.getInventroy();

^

It will work just as well as inventory or getInventory(). Despite being pointless.

 

 

Inventory i = client.getInventory();

 

cannot find symbol

 

try not to get hung up on the .inventory vs .getInventory() - you are missing the actual error in his code

Edited by MegaManAlpha
Posted (edited)

Inventory i = client.getInventory();

 

cannot find symbol

 

try not to get hung up on the .inventory vs .getInventory() - you are missing the actual error in his code

 

lol at the inventory vs. getInventory() thing. Not sure why you think I care about that

 

But you are correct, I thought Client extended API like all the other API classes, but it does not. Had it been anything but client (mouse, npcs, objects, players etc.) it would have been perfectly valid.

Edited by FrostBug

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...