Jump to content

Profit per hour


Ateria

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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