Jump to content

better way to count X logs chopped?


Recommended Posts

Posted (edited)

Code bellow works fine when we are not breaking, but when im breaking it fucks up and either goes up like 2+ extra logs even though we dont have that many logs.

example : we have chopped 200logs, but it returns 240 logs chopped.

		if(myPlayer() != null)
		{
		long oaksInInventory = getInventory().getAmount("Oak logs");
		if(oaksInInventory > oakpreviousInvCount){
			
			oakChopped += (oaksInInventory - oakpreviousInvCount);
			oakpreviousInvCount = oaksInInventory;
		} else if (oaksInInventory < oakpreviousInvCount){
			oakpreviousInvCount = oaksInInventory;
		}
        }

Reason im asking for some help or tips is because when we have X logs chopped i want it to do something.

Edited by atoo
Posted
12 minutes ago, atoo said:

Code bellow works fine when we are not breaking, but when im breaking it fucks up and either goes up like 2+ extra logs even though we dont have that many logs.

example : we have chopped 200logs, but it returns 240 logs chopped.


		if(myPlayer() != null)
		{
		long oaksInInventory = getInventory().getAmount("Oak logs");
		if(oaksInInventory > oakpreviousInvCount){
			
			oakChopped += (oaksInInventory - oakpreviousInvCount);
			oakpreviousInvCount = oaksInInventory;
		} else if (oaksInInventory < oakpreviousInvCount){
			oakpreviousInvCount = oaksInInventory;
		}
        }

Reason im asking for some help or tips is because when we have X logs chopped i want it to do something.

 

I believe there is a chatbox message you could listen for?

Override the onMessage method or add a message listener etc.

Or just divide XP gained by xp per log. XP gained can be obtained from the ExperienceTracker

  • Like 2
Posted

As Explv said, there are a numebr of ways. I'd probably rank (in terms of tidiness/reliability) them as follows:

  1. Message listener (easiest way is to override onMessage)
  2. Inventory listener - you'll have to implement this yourself
  3. Calculating from xp gain. Not ideal as it requires xp data which is subject to change, plus relies on being logged in and having valid xptracker data

 

  • Like 1
Posted
2 minutes ago, Apaec said:

As Explv said, there are a numebr of ways. I'd probably rank (in terms of tidiness/reliability) them as follows:

Calculating from xp gain. Not ideal as it requires xp data which is subject to change, plus relies on being logged in and having valid xptracker data

 

But it keeps the value of how much xp you have gained even though you log out, which is nice.

Posted
1 hour ago, atoo said:

But it keeps the value of how much xp you have gained even though you log out, which is nice.

Yeah, but you may find that if you start the script when logged out and stop the script before onStart currently executes, the exp-gained will be some very unpredictable (potentially massive) value as it is not initialised. Not a problem for runtime paint data, but if you start saving data this could be an issue.

  • Like 1
Posted
1 hour ago, Apaec said:

Yeah, but you may find that if you start the script when logged out and stop the script before onStart currently executes, the exp-gained will be some very unpredictable (potentially massive) value as it is not initialised. Not a problem for runtime paint data, but if you start saving data this could be an issue.

been botting for 2 hours and had 8 breaks.

seems to still work fine 8da8f250b4fdd413439241b14477aabf.png

  • Like 1
Posted
25 minutes ago, atoo said:

been botting for 2 hours and had 8 breaks.

seems to still work fine 8da8f250b4fdd413439241b14477aabf.png

 

2 hours ago, Apaec said:

Yeah, but you may find that if you start the script when logged out and stop the script before onStart executes, the exp-gained will be some very unpredictable (potentially massive) value as it is not initialised. Not a problem for runtime paint data, but if you start saving data this could be an issue.

 

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