View Full Version : *sigh* back with another script problem
Brandon
03-24-2011, 06:49 AM
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?..
'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?
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.
TomTuff
03-24-2011, 06:57 AM
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() ;)
Floor66
03-24-2011, 06:57 AM
'Pots made/Hour: ' + ToStr(Ceil(UnfPotsDone * 3600) / (GetTimeRunning / 1000)))
Brandon
03-24-2011, 07:04 AM
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?
TomTuff
03-24-2011, 07:20 AM
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.
Brandon
03-24-2011, 07:43 AM
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.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.