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.

client.getMyPlayer().getHealth()

Featured Replies

client.getMyPlayer().getHealth() is persistent between logouts/script runs. It only fixes itself when you go back into combat. This is a problem when I set my script to eat when my health is below a certain percent. 

What happens is:

1.) my health goes below 20 percent.

2.) the bot starts eating like it's supposed to.

3.) if I am in combat it will eat until I am above 20 percent health, if it isn't in combat, my health percent won't update so it will keep eating because it thinks i'm still below 20 percent health. I know this because I did some debugging. This is obviously not a problem with my script. Even though I could fix this issue by only checking my health when I am in combat, it is still an inconvenience nonetheless.

  • Author

Use client.getSkills().getCurrentLevel(Skill.HITPOINTS) instead. GetHealth() is just the hp bar.

Well I like getHealth() because it tells me the percent of health i have left. But ig I will just use that then :p thanks.

the health hooks only work while the local player is in combat or more specifically, while the combat bar is visible.

alternatively you could just use the skill api.

private int getHealthPercent() {

		final double currentHP = client.getSkills().getCurrentLevel(
				Skill.HITPOINTS);
		final double realHP = client.getSkills().getLevel(Skill.HITPOINTS);
		final double getHealthPercent = (currentHP / realHP) * 100;

		return (int) StrictMath.round(getHealthPercent);
	}

Here is a snippet purpleK gave me

 

How to use :

	public void eatFood() throws InterruptedException {
		if (getHealthPercent() <= hpPercent) {
			if (client.getInventory().contains(FOOD_ID)) {
				status = "eating food";
				client.getInventory().interactWithId(FOOD_ID, "Eat");
			}
		}
	}

Edited by NxJr

Guest
This topic is now closed to further replies.

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.