Jump to content

Mind correcting my broken code?


Trivial

Recommended Posts

i suck, pls help whats wrong with this idk

looks good to me

package Fisher;

import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.model.Entity;
import org.osbot.script.rs2.model.Player;
import org.osbot.script.rs2.ui.Inventory;

@ScriptManifest(
		author = "-", 
		info = "--", 
		name = "---", 
		version = 0
)
public class BarbarianFisher extends Script {

	final String FISHINGSPOT_NAME = "Fishing spot";

	public int onLoop() throws InterruptedException {

		Player player = client.getMyPlayer();
		Inventory inv = client.getInventory();

		if (!client.getInventory().isFull()) { // If inventory is not full then fish
			
			Entity fishSpot = closestObjectForName(FISHINGSPOT_NAME);

			if (fishSpot != null) {
				if (fishSpot.isVisible()) {
					if (!player.isAnimating()) {
						fishSpot.interact("Use-rod");
						sleep(200 + random(400));
					}
				} else {
					client.moveCameraToEntity(fishSpot);
				}
			}

		} else {
			// If inventory is full then drop all except feathers and rod
			inv.dropAllExcept(314,11323);
		}

		return 50;
	}
}
Edited by Damighty
Link to comment
Share on other sites

Let me guess it would turn the camera to the entity but not actually use the rod on the spot? This should fix it. Read my signature for my TOS lol.

        final String FISHINGSPOT_NAME = "Fishing spot";
        final int rod = 11323;
    	public int onLoop() throws InterruptedException {

    		Player player = client.getMyPlayer();
    		Inventory inv = client.getInventory();

    		if (!client.getInventory().isFull()) { // If inventory is not full then fish
    			
    			Entity fishSpot = closestNPCForName(FISHINGSPOT_NAME);

    			if (fishSpot != null) {
    				if (fishSpot.isVisible()) {
    					if (!player.isAnimating()) {
    						inv.interactWithId(rod, "Use-rod");
    						selectOption(fishSpot, fishSpot.getMouseDestination(), "Use-rod");
    						sleep(200 + random(400));
    					}
    				} else {
    					client.moveCameraToEntity(fishSpot);
    				}
    			}

    		} else {
    			// If inventory is full then drop all except feathers and rod
    			inv.dropAllExcept(314,rod);
    		}

    		return 50;
    	}
Edited by Fay
Link to comment
Share on other sites

Seems like that did the trick, thank you! But I'm sure there should be a way to just make it simply click on the fishing spot instead of using the rod itself on the fishing spot, that seems kinda silly. It does it really fast though so I guess it'll be fine. Thanks a bunch for the help

 

Yeah there is but you didn't ask for that, you just asked to fix the script :).

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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