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
  • Best way to make script wait while logged out?


    Zenarchist

    Recommended Posts

    Hey guys, I'm new to Dreambot (but not Java) and am just wondering what is considered best practice for making your script handle world hopping and logouts?

    The problem I am having is that sometimes when my character logs out or world hops, this inventory.count() == 0 guard clause returns true and stops my script:

    // If our player model hasn't loaded or we are logged out, wait.
    
    if(!getLocalPlayer().exists() || !getClient().isLoggedIn())
        return Calculations.random(3000, 6000);
    
    // Check that we have a net
    
    if(getInventory().count(303) == 0) {
        stop();
        log("Error - No net!");
        return 1;
    }

    Any ideas why the first check isn't stopping my script from prematurely performing the second check on my inventory when my character isn't logged in yet / my inventory hasn't loaded? This only happens rarely and if I run the script for a long time, and I do use VPNs, so I believe random lag/disconnection is probably a factor. But what are your guys' methods for handling this type of situation? Am I missing something?

     

    Thanks heaps!

    Regards, Zen 

    Link to comment
    Share on other sites

    you wanna give it an extra check something like that 

    if(getInventory().count(303) ==0&&getClient().isLoggedIn()) {
        stop();
        log("Error - No net!");
        return 1;
    } so it wont stop script unless it has no net and account is already logged in.... that solution might not be ideal tho but itll work 

    Feel free to add me on discord  or ask me here for any more help :)

    Link to comment
    Share on other sites

    Ahhh good idea man, I didn't think of trying that. Cheers bro! I'll give it a go and let you know if it fixes the problem :) 

    And thanks for the offer, I might take you up on that sometime. I could use some occasional advice from an experienced Dreambotter, I'm super rusty with bot apis (and osrs for that matter lol)

    Link to comment
    Share on other sites

    Thanks a lot for the tips guys! I really appreciate it. like how helpful this community is, it's one of the reasons I came back to OSRS botting even though I don't really game anymore haha. It's great fun!

    I tried sadgonzer's suggestion last night but it didn't help. I could easily move the check into onStart() and it will not be a problem, but then if I bug out and drop my net (has never happened to me but I like to prepare for everything), the bot is going to just stand there logging in and out for hours lol. Guaranteed banhammer.

    Anyway thanks for the tips Miami 369 & ArmyofDragons, I'll definitely look into that. And great advice Hashtag, nothing is worse than stopping your script and it gets stuck in a loop moving your mouse around and you need to restart the bot lol.

    Surely one of these methods will work, I'll get experimenting and let you guys know if I sort it out. Cheers!

    Link to comment
    Share on other sites

    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.