Jump to content

Interactable Paint - Not working on OSBot 2 .. ?


BrownBird

Recommended Posts

I've made all my scripts with intractable paints.. The code I am currently using doesn't work?

boolean hide;
Point p;
Rectangle hideBox = new Rectangle(52, 41, 70, 81);

public void mouseEntered(MouseEvent e) {
     p = e.getPoint();
     
         if(hideBox.contains(p) && !hide) {
         hide= true;
         } else if(hideBox.contains(p) && hide){
         hide = false;
         }
 } 

and then in the paint section..

 

if (!hide) {

        g.drawString("Showing Paint...", 0,0)

  } else {

        g.drawString("Not Showing PAint...",0,0)

 
Thanks for the help!smile.png
Edited by BrownBird
Link to comment
Share on other sites

 

I've made all my scripts with intractable paints.. The code I am currently using doesn't work?

boolean hide;
Point p;
Rectangle hideBox = new Rectangle(52, 41, 70, 81);

public void mouseEntered(MouseEvent e) {
     p = e.getPoint();
     
         if(hideBox.contains(p) && !hide) {
         hide= true;
         } else if(hideBox.contains(p) && hide){
         hide = false;
         }
 } 

and then in the paint section..

 

if (!hide) {

        g.drawString("Showing Paint...", 0,0)

  } else {

        g.drawString("Not Showing PAint...",0,0)

 
Thanks for the help!smile.png

 

public class BotMouseListener implements MouseListener {
		@Override
		public void mouseClicked(MouseEvent e) {
                       // TODO Auto-generated method stub
		}

		@Override
		public void mouseEntered(MouseEvent e) {
			// PUT YOUR MOUSE CODE HERE!!!!!!!!            

		}

		@Override
		public void mouseExited(MouseEvent e) {
			// TODO Auto-generated method stub

		}

		@Override
		public void mousePressed(MouseEvent e) {
			// TODO Auto-generated method stub

		}

		@Override
		public void mouseReleased(MouseEvent e) {
			// TODO Auto-generated method stub

		}

	}
// IN onStart METHOD!
MouseListener bml = new BotMouseListener();
bot.addMouseListener(bml);
Link to comment
Share on other sites

here, example usage of how to hide a paint:

 

 

declare your hide and show images at the top of your script with your variables:

private final Image showImage = getImage("http://s28.postimg.org/hcce8fx9l/show_fw.png");
private final Image hideImage = getImage("http://s29.postimg.org/8g0qpcipv/hide_fw.png");

you need a tiny method to grab images from the internet, so put this below the above:

private Image getImage(String url)
		  {
		    try
		    {
		      return ImageIO.read(new URL(url));
		    }
		    catch (IOException e) {}
		    return null;
		  }

next you need to declare your point to click on so put this below the above with your other variables ^ :

Point p;

next you need your boolean for whether your paint is hidden or not and declare it, put this below the above:

	  	boolean hide = false;

next you need two rectangles, one for where you click to hide the paint and the next for where you click to show it, declare these with your variables to:

(check the api to find out which numbers are which)

	  	Rectangle close = new Rectangle(10, 457, 118, 20);
		Rectangle open = new Rectangle(10, 457, 118, 20);

now in your onStart() method you need to put this:

	    bot.addMouseListener(new MouseListener() {//register a new MouseListener
            @Override
            public void mouseClicked(MouseEvent e) {
        	    p = e.getPoint();
        	    if (close.contains(p) && !hide) {
        	        hide = true;
        	    } else if (open.contains(p) && hide) {
        	        hide = false;
        	    }
            }

            @Override
            public void mousePressed(MouseEvent e) {

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });

next you need to sort out your onPaint method, so that you have two if statements like this:

	public void onPaint(Graphics2D g)
	  {
	    Graphics2D gr = g;
		  if (!hide)
		  {
                    // put your paint in here e.g:
                    g.drawString(ft(timeRan), 295, 349);
                  }
                  
                  if (hide) 										  {
                    // here you put the image to show when your paint is hidden e.g:
		    g.drawImage(this.showImage, 10, 457, null);
		  }
          }

if you have any more questions, pm me.

a like for this post wouldnt go a miss it took a little while lol.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...