Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Profit per hour

Featured Replies

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

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)

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

  • Author
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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.