September 29, 201510 yr Morning, I have my MouseEvent, rectangle and booleans; I've tried to add the MouseLisenter with @Override yet nothing happens. Also when adding in MouseLisenter it adds other unneeded methods.. Any help is much appreciated thank you!
September 29, 201510 yr Developer Morning, I have my MouseEvent, rectangle and booleans; I've tried to add the MouseLisenter with @Override yet nothing happens. Also when adding in MouseLisenter it adds other unneeded methods.. Any help is much appreciated thank you! Just add this to your onStart(); There are better ways to do it, but this is the most easy ^^ bot.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseClicked(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } }); Edited September 29, 201510 yr by Khaleesi Scripts
September 29, 201510 yr Thanks, instead I just put it into my paint method to keep it clean You wat? Just making sure here; but you should under no circumstance register the event listener in onPaint :E
September 29, 201510 yr Author You wat? Just making sure here; but you should under no circumstance register the event listener in onPaint :E Why not? lol.. It seems to be running just fine, is there something else I wouldn't know about?
September 29, 201510 yr Why not? lol.. It seems to be running just fine, is there something else I wouldn't know about? Do you hate us or something? Has OSBot wronged you in any way?
September 29, 201510 yr Author Do you hate us or something? Has OSBot wronged you in any way? Oh my.. something occurred without me knowing
September 29, 201510 yr Why not? lol.. It seems to be running just fine, is there something else I wouldn't know about? Well, onPaint is called 60 times per second (or 30, I don't remember). The bot holds a collection of MouseListeners. Each time you register a listener, it's added to this collection. Registering 60 new mouse listeners per second is not only a fairly critical memory leak; but will increase your CPU usage over time, since every single mouse event has to be processed by the constantly growing number of listeners ;o. I'm fairly surprised if you've been able to run it for ~30 minutes without seeing poor performance Edited September 29, 201510 yr by FrostBug
September 29, 201510 yr Author Well, onPaint is called 60 times per second (or 30, I don't remember). The bot holds a collection of MouseListeners. Each time you register a listener, it's added to this collection. Registering 60 new mouse listeners per second is not only a fairly critical memory leak; but will increase your CPU usage over time, since every single mouse event has to be processed by the constantly growing number of listeners ;o. I'm fairly surprised if you've been able to run it for ~30 minutes without seeing poor performance That's what I initially thought when you said this but I've ran it for about 3 hours today with CPU usage staying under 20%, now I'm not quite sure if that's high or not for a single script but it hasn't went past this at all.. Also been browsing the web and such, now for memory i haven't been keeping an eye on that. I will as of now! Edit: I think I understand why I haven't noticed any performance loss.. I have a memcleaner program installed; clearing it every 5 minutes.. Edited September 29, 201510 yr by BrownBird
September 29, 201510 yr That's what I initially thought when you said this but I've ran it for about 3 hours today with CPU usage staying under 20%, now I'm not quite sure if that's high or not for a single script but it hasn't went past this at all.. Also been browsing the web and such, now for memory i haven't been keeping an eye on that. I will as of now! Edit: I think I understand why I haven't noticed any performance loss.. I have a memcleaner program installed; clearing it every 5 minutes.. Well, you can easily debug it. int totalListeners = bot.getMouseListeners().size(); If this is constantly increasing, then you have a memory leak Edited September 29, 201510 yr by FrostBug
September 30, 201510 yr Unfortunately there is a leak, I'll have to put it in my onStart If it's because of the unwanted methods then create a class and extend mouse adapter. Then add that class to the bit's mouselistener
October 1, 201510 yr Well, onPaint is called 60 times per second (or 30, I don't remember). The bot holds a collection of MouseListeners. Each time you register a listener, it's added to this collection. Registering 60 new mouse listeners per second is not only a fairly critical memory leak; but will increase your CPU usage over time, since every single mouse event has to be processed by the constantly growing number of listeners ;o. I'm fairly surprised if you've been able to run it for ~30 minutes without seeing poor performance I think onPaint (in this context) would be called 50 times per second (syncing with the RS client). The reason we add our listeners in onStart is because otherwise we're creating a new listener 50 times per second (every 20ms), as well as assigning it to the bot to listen. When we click then, something along this would occur: //when clicked for (MouseListener ml : listeners) ml.onClick(mouseArgs); So that means your mouse listeners will also be executing many times in tandem.
Create an account or sign in to comment