Jump to content

better way to count X logs chopped?


atoo

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

 

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