Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • MessageListeners behaviour


    RK420

    Recommended Posts

    Posted

    Hello everyone!

    I'm pretty new to scripting, and have been practicing by making a bot for nightmare zone. I use the MessageListener for reading the game messages and detecting my remaining absorption charges and to know when I need to drink a new dose of overload. Now my question is, how does the MessageListener interact with the OnLoop() from AbstractScript? An example in pseudocode:

    OnLoop() {
    	Do_thing_1()
    	Sleep(5000)
    }
    
    OnGameMessage(Message) {
    	if (Message == "Overload is over") {
    		Do_thing_2()
    		Sleep(20000)
    	}
    }

    When the overload is over, will the bot do nothing for 20 seconds, or will it still do thing 1 every 5 seconds while not reading any messages for 20 seconds?

    Thanks

    Posted

    message listeners are on a seperate thread. sleeping there will only cause that thread to sleep, not the onloop thread.

    Posted

    Use a boolean flag, toggle it on the message listener method and check that flag on the onloop

    Posted

    You can use Widget and WidgetChild to just get the current Absorption number that is on the Nightmare Zone UI, that's what I did for my own NMZ script.

    Posted
    4 hours ago, Neffarion said:

    Use a boolean flag, toggle it on the message listener method and check that flag on the onloop

    I've been using a boolean flag 'ovling' which indicates whether my character is drinking overload or not. Because the bot should not eat dwarven rock cake to lower its hitpoints if its ovling. This boolean flag becomes true when the message listener detects the ovl is over, but for some reason my character eats dwarven rock cake, even though its ovling. This made me think that the OnLoop() function gets called BEFORE the listener puts this boolean flag on true. Is this possible? I'm really confused right now. The message listener should get priority over the loop function, but i'm not sure that's true.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.