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
  • for loop, unused variable help?


    Banker

    Recommended Posts

    Posted

    Okay so im working on a script that involves a spammer (as you can already tell from the code below), I'm trying to have it where i can stop/start the spamming at any point.

     

    When i try have the wait (return wait;) between messages the final part of the for loop code is reporting as unused, when i remove the return statement it is 'used' again and the warning disappears.

     

    Code:

    for(x = 0; x<messages.size(); x++) {
    				getKeyboard().type(messages.get(x));
    				//return wait;
    			}
    

    Note: messages is an ArrayList<String> && the variable 'x' is created at the top of the code.

    public int x = 0;
    

     This is so i can perform checks on the positioning of the bot, outside of the loops.

     

    Thanks.

    Posted

    What's the point of the loop if you just return out of it the first time it's called?

    Posted

    What's the point of the loop if you just return out of it the first time it's called?

     

    shit, that would be the issue then, would sleep(wait); be more appropriate in having time between each message.

     

    Was pretty tired when i wrote it so mustve used return my mistake and not realised

    Posted

    shit, that would be the issue then, would sleep(wait); be more appropriate in having time between each message.

     

    Was pretty tired when i wrote it so mustve used return my mistake and not realised

    Yes, a return breaks the loop and returns the value of the wait variable.

    If you want the loop to wait a certain amount of seconds before executing again, you should use the sleep function

    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.