Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
peanuts1079

Weird bot behavior and bugs

Recommended Posts

Hi,

I am trying to write a script and I am seeing weird client-sided bugs. Here is an example of code I am running

RSItem[] item = Inventory.find("Item");
if(item.length > 1){
doSomething();

}else{
doSomethingElse();

}

In-game, I will have 1 of the item in my inventory and doSomethingElse() is invoked. 

So essentially there must be an error with getting the length of inventory items because doSomethingElse() should only be called if there are less than 1 rings in the inventory aka 0, which is wrong because there is 1 and thus neither doSomething() or doSomethingElse() should be called. 

I am also just generally noticing weird behavior and clicks. For some reason the bot hovered very quickly over each individual item in my inventory after it closed the bank and I definitely have no code in my script to do that. It's just so weird. 

 

Edited by peanuts1079

Share this post


Link to post
Share on other sites

Hey,

You specified that 'if item length is more than 1' do something (so a minimum value of 2), otherwise do something else.

'doSomethingElse()' is called because the value was less than 2.

You can get your desired behavior by using 'else if' or '=='.

I recommend using the Tribot method "println()" if you suspect something is off.

Eg. println(item.length), then you see the value in Tribots client debug under the client as you run the script.

As for the weird behavior and clicks I believe it's the Tribots antiban thats implemented in every script by default, the only way I know to disable this is to use this code on start.

@Override
public void run() {
  
  //This code to disable the antiban.
  for(Thread thread:Thread.getAllStackTraces().keySet()){
              if(thread.getName().contains("Antiban")||thread.getName().contains("Fatigue")){
                  thread.suspend();
              }
          }
 
  //Your loop 
  while(true) {
   		
  }
  
}

Hope this helps.

Share this post


Link to post
Share on other sites

What your looking for is 

if(item.length >= 1){

To check if it's over or equal to 1.

As for the weird behavior, the AI antiban doesn't hover over all the items in your inventory, so you should probably double check what's going on in your code, not sure what your doing so it's hard for me to suggest what may be happening but if your interacting with items in your inventory it's probably you causing the weird behavior.

A great tip is to print out whatever your having issues with, like if your having problems dealing with length checks, print the length before the check, with that you know if you did something wrong or not when checking the length.

  • Like 1

Share this post


Link to post
Share on other sites
if (item.length > 1) {
  doSomething();
} else {
  doSomethingElse();
}

 

 

7 hours ago, peanuts1079 said:

doSomethingElse() should only be called if there are less than 1 rings in the inventory

In the above code, the if block is executed if there are 2 or more items in the inventory. In any other case, the else block is executed.

Since you can't have a negative amount of items in the inventory, "any other case" means having 0 or 1 items in the inventory. Any of those values will result in the else block being executed.

 

As far as I can tell, you are trying to make a decision based on the availability of a certain item. If so, you could either do what @Zully suggested and evaluate the expression

item length >= 1

, or check if there are more than 0 items available:

item length > 0

 

They both translate to: "if there is any item in the inventory, then...".

 

Share this post


Link to post
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.

Sign in to follow this  

  • Our picks

    • This update features:

      Fixed broken hooks from today's update


      Fix wilderness level with RuneLite (Thanks @Todd)


      Add support for Kotlin .class files in scripts (Thanks @wastedbro)


      Overhaul Inventory API (Thanks @wastedbro)


      Add List support for common methods


      Change method grouping to make more sense (by functionality)


      Refactor methods to utilize Java 8 streams instead of cumbersome loops




      Recognize chatbox minimization (Thanks @JoeDezzy1)


      Fix Screen#isInViewport when NPC chat is open (Thanks @JoeDezzy1)


      Fix login bot bugs (Thanks @erickho123)


      Fix hint arrow return values (Thanks @Encoded)


      Fix depositAllExcept functionality (Thanks @wastedbro)


      Change containing box interface bound and adjust for Y values (Thanks @erickho123)
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
    • This release will:

      Add new internal framework for capturing exceptions


      Fix issue with not selecting the last column in world hopper (Thanks @Todd)


      Add a message about pin usage in Banking#openBank (Thanks @Todd)


      Disable the firewall by default (Thanks @Todd)


      Fix handling of the welcome screen after login (Thanks @Encoded)


      Fix wrong amount bank withdrawal (Thanks @Encoded)


      Fix Screen#isInViewport


      Fix Game#isInViewport (Thanks @Encoded)


      Call onBreakEnd for ListenerManager Breaking Listeners (Thanks @Encoded)


      Fix Prayer#getPrayerPoints NumberFormatException (Thanks @JoeDezzy1)



      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Thanks
        • Like
      • 28 replies
    • This release will:

      Fix LG for both OSBuddy and RuneLite


      Fix issue where the resizable client isn't able to be made smaller (Thanks @JoeDezzy1)


      Fix detection of the logout game tab when resizable mode and side panels are enabled (Thanks @JoeDezzy1)


      Add initial support for Sentry to allow us to identify and easily debug exceptions happening with all TRiBot users


      Add methods to determine if the bank is actually loaded, and not just the overarching interface (Thanks @wastedbro)



      Upcoming updates:

      Improved CLI support


      Full Sentry support


      Much more
        • Like
      • 64 replies
    • This release will:

      Fix NPE in Camera API (Thanks @wastedbro)


      Update deposit box interface ids (Thanks @Encoded)


      Add various bank methods (Thanks @wastedbro)


      Banking#getWithdrawXQuantity


      Banking#getDefaultWithdrawQuantity


      Banking#arePlaceholdersOn




      Fix resizeable minimap bug (Thanks @wastedbro)


      Remove Java 8 requirement


      Please note: TRiBot is not yet fully compatible with Java 10+




      Fix the break handler issues by ensuring the break handler thread never gets paused


      Fix broken settings hooks



      Upcoming updates:

      Improved CLI support


      Much more



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 68 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...