Results 1 to 7 of 7

Thread: *sigh* back with another script problem

  1. #1
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default *sigh* back with another script problem

    I have the following piece of code for the progress report in a herblore bot that counts how many pots the bot made per hour.. Im pretty sure that its the right formula?..

    Simba Code:
    'Pots made/Hour: ' + ToStr(Ceil(UnfPotsDone * 60 * 60 * 1000) / GetTimeRunning))

    Anyway It doesnt work and I dont know why.. This is what happened:

    TimeRunning: 20m 14s
    Pots Made: 672
    Pots Made/Hour: -1544 <--- Problem.. and it keeps getting even more negative... atm its at -236 now, 10 seconds later its at -180..

    What am I doing wrong?? Am I supposed to use Players worked instead? (not even near as accurate for some reason).

    Thing is it works fine and counts the pots made/hr perfectly up until it hits the 18-19 minute mark and then it goes negative and just decreases in value. I tried Int64ToStr, I tried IntToStr, ToStr. None worked..

    Edit: At 37minute mark, its back up to positive 17... but it makes no sense.. 17 pots/hr wth?

  2. #2
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    GetTimeRunning will mess things up when you use multiplayer. You can also use marktime at the beginning of the session, then subtract it from GetTimeRunning etc.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  3. #3
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Formula for EXP per hour:
    (TOTAL OF VALUE * 60.0)/(TIME / 60000.0)
    Time should probably be PlayerWorked(WhichPlayer), and time is some number in your script. Be sure to wrap that in Round()

  4. #4
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Simba Code:
    'Pots made/Hour: ' + ToStr(Ceil(UnfPotsDone * 3600) / (GetTimeRunning / 1000)))
    Ce ne sont que des gueux


  5. #5
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Hmm I thought the Ceil would round it up wouldnt it?? As for negative numbers.. that should happen at all since GetTimeRunning is a LongWord type.. which is an integer that holds only positive values.. So why does it turn negative at the 17.5 mark and turn back positive after another 17.5 mark?

    Also PlayerWorked is an integer.. and the result is an integer so why round it?
    Last edited by Brandon; 03-24-2011 at 07:08 AM.

  6. #6
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by ggzz View Post
    Hmm I thought the Ceil would round it up wouldnt it?? As for negative numbers.. that should happen at all since GetTimeRunning is a LongWord type.. which is an integer that holds only positive values.. So why does it turn negative at the 17.5 mark and turn back positive after another 17.5 mark?

    Also PlayerWorked is an integer.. and the result is an integer so why round it?
    because it OBVIOUSLY doesn't work the way. also, don't forget the .0 after (so 10.0 rather than 10). You need Simba to temporarily hold it as an extended until you divide it again, otherwise it will do 0/whatever, ergo giving the wrong number. As for the negative issue, that's because you used GetSystemTime. Just do it this way... it works, so don't try and testify against it.

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    because it OBVIOUSLY doesn't work the way. also, don't forget the .0 after (so 10.0 rather than 10). You need Simba to temporarily hold it as an extended until you divide it again, otherwise it will do 0/whatever, ergo giving the wrong number. As for the negative issue, that's because you used GetSystemTime. Just do it this way... it works, so don't try and testify against it.
    LOLOL! I wasn't going to testify it (Nor would I argue with u since I learned all my scripting from reading yours), I was just curious as to why it does that since they were both positive values. And yes I have done it the way you said and it works perfectly Thank you good sir.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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