Jump to content

Profit per hour


Recommended Posts

Posted (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 by Ateria
Posted (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 by battleguard
Posted (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:

yZ241Sv.png

Edit: Nevermind, this code works as intended, thanks @battleguard

double profitPerHour = (long) (looted * (3600000.0 / elapsedTime))/(hours <= 0 ? 1 : hours); 

 

Edited by Ateria
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...