Ateria Posted March 31, 2018 Share Posted March 31, 2018 (edited) I have two integers, looted (the total price of all items looted) and the current running time in hours/minutes/seconds. To get the profit per hour initially, I did looted / (hours <= 0 ? 1 : hours) The problem with this is, it will only update hourly, and it'll almost always be incorrect as it only goes by the hours. So the script would need to be run for a minimum of 1 hour, then it would only update every hour. Is it possible to get the current estimated profit per hour from these two integers? (so it'll update every second with an estimated hourly profit) Edited March 31, 2018 by Ateria Quote Link to comment Share on other sites More sharing options...
GPSwap Posted March 31, 2018 Share Posted March 31, 2018 make yourself timeInHours by doing runtime/1hour(in ms) then you can just do profit/timeInHours for your hourly rate (there is probably a better way but it works) Quote Link to comment Share on other sites More sharing options...
battleguard Posted March 31, 2018 Share Posted March 31, 2018 (edited) double profitPerHour = (long) (profit * (3600000.0 / elapsedTimeMs)); This is pretty basic logic but it works like this: Total Profit / TotalTimeElapsedInMilliseconds = Profit per Millisecond Then since you want it in hours you times it by the number of milliseconds in an hour (3600000) to now get profit per hour Edited March 31, 2018 by battleguard Quote Link to comment Share on other sites More sharing options...
Ateria Posted March 31, 2018 Author Share Posted March 31, 2018 (edited) 8 hours ago, battleguard said: double profitPerHour = (long) (profit * (3600000.0 / elapsedTimeMs)); This is pretty basic logic but it works like this: Total Profit / TotalTimeElapsedInMilliseconds = Profit per Millisecond Then since you want it in hours you times it by the number of milliseconds in an hour (3600000) to now get profit per hour The profit is way off with that, this is the code now: double profitPerHour = (long) ((looted * (3600000.0 / elapsedTime))*3600000)/(hours <= 0 ? 1 : hours); and here's the estimated profit after running for 16 mins: Edit: Nevermind, this code works as intended, thanks @battleguard double profitPerHour = (long) (looted * (3600000.0 / elapsedTime))/(hours <= 0 ? 1 : hours); Edited March 31, 2018 by Ateria 1 Quote Link to comment Share on other sites More sharing options...