Page 3 of 13 FirstFirst 1 2 3 4 5 ... LastLast
Results 21 to 30 of 124

Thread: MMG Martingale script

  1. #21
    Junior Member
    Join Date
    Mar 2009
    Location
    Western, USA
    Posts
    16

    Default

    Ok, we can start here then.
    I want to return a meat result directly from the bet page. It is much faster than going to the betarchive. I don't know about you, but it takes forever for me to load the archive. I also don't have meat coming in from anywhere else to change the values of this result, so we are safe that way.

    Code:
    int total() {
       if usehagnksmeat = false {
       string s = visit_url("bet.php");
       s = substring(s,index_of(s,"You have"),index_of(s,"Meat on hand"));
       int result = to_int(s);
       }
       else {
       string s = visit_url("bet.php");
       s = substring(s,index_of(s,"hand and"),index_of(s,"Meat in Hagnk's"));
       int result = to_int(s);
       }
       print("Meat available: "+result);
       return result;
    }
    If I have done this right, result should return a value of either hagnks or on hand. That is assuming I have understood the functions correctly.

  2. #22
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,559

    Default

    Looks like it should work, although you need parentheses around conditions for if statements. Best way is to make a test script to try it out:

    testavailablemeat.ash
    Code:
    boolean usehagnksmeat;
    
    int total() {
       if (!usehagnksmeat) {
       string s = visit_url("bet.php");
       s = substring(s,index_of(s,"You have"),index_of(s,"Meat on hand"));
       int result = to_int(s);
       } else {
       string s = visit_url("bet.php");
       s = substring(s,index_of(s,"hand and"),index_of(s,"Meat in Hagnk's"));
       int result = to_int(s);
       }
       print("Meat available: "+result);
       return result;
    }
    
    void main(boolean usehagnks) {
       usehangksmeat = usehagnks;
       print("Checking available meat...");
       total();
    }
    The only problem with checking bet.php is that you might get a kmail that changes your available meat, or you might sell something in your store. If you don't have a store that's fine but kmails are a different issue.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossna | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  3. #23
    Junior Member
    Join Date
    Mar 2009
    Location
    Western, USA
    Posts
    16

    Default

    My character I want this script for is not avery social character so it isn't going to be a huge problem with incoming meat possibilities. I also wanted to do it this way for the speed of the check. It is quite a bit faster than checking the archive.

    Now for a quick question. Why does it need to be - if (!usehagnksmeat) Why the (!) , and why does it not need a qualifying equals to a value?

    Also when I try to run the above test script, it has an error. Script parsing error (testavailablemeat.ash, line 1).

  4. #24
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,559

    Default

    If statements (and while and repeat loops) require conditions, like so:

    if ( condition ) { commands }

    Conditions must evaluate to a boolean, i.e. true or false. When you use a boolean value as a condition, it evaluates to true or false without needing an operator like "==" or "<".

    So instead of (usehagnksmeat == true) you can just use:

    if (usehagnksmeat) print("Using Hagnk's.");

    Also, ! means "not". So instead of (usehagnksmeat == false) you can use:

    if (!usehagnksmeat) print("Not using Hagnk's.");

    This is useful for functions that return a boolean value, for example:

    if (!retrieve_item(1,$item[turtle totem]))
    print("You were unable to get the item.");


    As far as the test script, I made a few changes to it, and now it works:

    Code:
    boolean usehagnksmeat;
    
    int total() {
       string s = visit_url("bet.php");
       if (!usehagnksmeat)
          s = substring(s,index_of(s,"Add a Bet:"),index_of(s,"Meat on hand"));
       else s = substring(s,index_of(s,"hand and"),index_of(s,"Meat in Hagnk's"));
       int result = to_int(s);
       print("Meat available: "+result);
       return result;
    }
    
    void main(boolean usehagnks) {
       usehagnksmeat = usehagnks;
       print("Checking available meat...");
       total();
    }
    Feel free to ask about any of the changes.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossna | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  5. #25
    Junior Member
    Join Date
    Mar 2009
    Location
    Western, USA
    Posts
    16

    Default

    I don't know if I am doing something wrong or not. I tried to run this new script and I still get a parsing error. As for the changes, all that was really changed was to clean things up a little. I get that part. Also thanks for explaining the (!), that helps alot.

  6. #26
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,559

    Default

    What are you using to make the file? I can run the last posted code just fine.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossna | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  7. #27
    Junior Member
    Join Date
    Mar 2009
    Location
    Western, USA
    Posts
    16

    Default

    I am using wordpad to edit and save the files.

  8. #28
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    wordpad is not ideal. notepad is much better for this. wordpad can get you in trouble by saving formatting characters if you're not careful.

    If that still doesn't work, attach your script to your next reply so we can download it and check it ourselves.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  9. #29
    Junior Member
    Join Date
    Mar 2009
    Location
    Western, USA
    Posts
    16

    Default

    Ok, saved it using notepad and it did work.

    I now have a working betting script. Just one problem. It only runs through the bets once, and if it wins it stops. How can I get it to run through and then start again at the beginning?
    Last edited by tamahome; 03-17-2009 at 11:00 PM.

  10. #30
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,559

    Default

    Change the name of your main() function, say to betchain(). Then make a new main() that calls betchain() X times.

    Code:
    betchain() { previous main() function }
    
    main(int numchains) {
       for i from 1 to numchains
          betchain();
    }
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossna | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

Similar Threads

  1. Script Registry -- for script authors; track your script usage
    By zarqon in forum Informational Scripts
    Replies: 211
    Last Post: 07-19-2018, 07:05 AM
  2. Replies: 1
    Last Post: 09-28-2015, 10:43 PM
  3. Replies: 0
    Last Post: 06-09-2015, 01:53 PM
  4. Replies: 1
    Last Post: 05-09-2012, 04:02 AM
  5. Replies: 0
    Last Post: 02-19-2012, 10:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •