Jump to content

How do I make a loot counter?


Recommended Posts

Posted

I made a simple Kebab Buying script, but how would I keep track of how many are bought? I've tried having it get the amount of the inventory but I can't seem to figure out how to keep it adding onto a number. I tried to do a KebabCount = KebabCount + 1 after the dialogue where the Kebab is bought but nope.

 

ALSO, if you're reading this, what would be my best way of walking my player from Al Kharid to the GE so he can sell the Kebabs. Not planning on adding this yet but just wondering.

Posted (edited)

I made a simple Kebab Buying script, but how would I keep track of how many are bought? I've tried having it get the amount of the inventory but I can't seem to figure out how to keep it adding onto a number. I tried to do a KebabCount = KebabCount + 1 after the dialogue where the Kebab is bought but nope.

 

ALSO, if you're reading this, what would be my best way of walking my player from Al Kharid to the GE so he can sell the Kebabs. Not planning on adding this yet but just wondering.

int kebabCount;

//After you get a full inventory and head to the bank.
//before you open the bank
kebabCount += getInventory().getAmount("name of item");

for walking

 

grab a position near the GE

WebWalkEvent toGE = new WebWalkEvent(INodeRouteFinder.createAdvanced(), new Position(0,0,0));
context.execute(toGE);

hope this helps

Edited by Sinatra
  • Like 2
Posted

Does it say in chat when you buy a kebab? You could use the message listener in that case and just +1 everytime it pops up in chat, you could alternatively create your own inventory listener kind of thing, but its pretty unnecessary for this.

 

It does! How would I do this message listener? Never heard of it tbh.

  • Like 1
Posted

It does! How would I do this message listener? Never heard of it tbh.

 

 

I'm on my at the moment so i'm not going to dig through the API

 

But its an interface called MessageListener that you implement, and it will give you  a method like

 

public void onMessage(Message m)

 

e.g.

 

public class Test implements MessageListener

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