Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

omgwizzle

First time scripting, script repeatedly clicking starting tile.

4 posts in this topic

Quote

package scripts.TestWoodCutter; import org.tribot.api.General; import org.tribot.api.input.Mouse; import org.tribot.api2007.*; import org.tribot.api2007.types.RSNPC; import org.tribot.api2007.types.RSTile; import org.tribot.script.Script; import org.tribot.script.ScriptManifest; import static org.tribot.api.General.random; /** * Created by Letlo on 7/12/2016. */ @ScriptManifest(authors = "Omgwizzle", name = "scripts.idk", category = "Combat") public class idk extends Script { private RSNPC[] npc; private RSNPC nearest; private RSTile SAFE; private boolean False = false; public int randomness; @Override public void run() { startScript(); while (loop()) { } } private void startScript() { Mouse.setSpeed(105); SAFE = Player.getPosition(); } public boolean loop() { if (False) { } else { attack(SAFE); } return true; } public void attack(RSTile startTile) { npc = NPCs.findNearest(15, 2515); nearest = npc[0]; if (!Player.getRSPlayer().isInCombat() && !nearest.isInCombat()) { randomness = 1 + General.random(1, 99); if (nearest.isOnScreen()) { if ((randomness > 50)) { nearest.click("Attack"); sleep(1500, 2250); } else { Mouse.click(nearest.getModel().getTriangles()[0].getBounds().getLocation(), 1); sleep(1500, 2250); } } else { Camera.turnToTile(nearest.getPosition()); } } else if (Player.getPosition() != startTile) { Walking.walkTo(startTile); sleep(600, 940); } } }

Trying to get my script to attack a monster with a safespot. If my character is not on the safespot I want the script to click back on the tile, but even when on the tile it only clicks that.

Share this post


Link to post
Share on other sites
29 minutes ago, omgwizzle said:

Trying to get my script to attack a monster with a safespot. If my character is not on the safespot I want the script to click back on the tile, but even when on the tile it only clicks that.

Try reposting your code into a code formatting rather than quote formatting

Share this post


Link to post
Share on other sites
package scripts.TestWoodCutter;

import org.tribot.api.General;
import org.tribot.api.input.Mouse;
import org.tribot.api2007.*;
import org.tribot.api2007.types.RSNPC;
import org.tribot.api2007.types.RSTile;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

import static org.tribot.api.General.random;


/**
 * Created by Letlo on 7/12/2016.
 */


@ScriptManifest(authors = "Omgwizzle", name = "scripts.idk", category = "Combat")
public class idk extends Script {


    private RSNPC[] npc;
    private RSNPC nearest;
    private RSTile SAFE;
    private boolean False = false;
    public int randomness;


    @Override
    public void run() {
        startScript();
        while (loop()) {

        }
    }

    private void startScript() {

        Mouse.setSpeed(105);
        SAFE = Player.getPosition();

    }


    public boolean loop() {

        if (False) {

        } else {
            attack(SAFE);

        }
        return true;
    }

    public void attack(RSTile startTile) {
        npc = NPCs.findNearest(15, 2515);
        nearest = npc[0];
        if (!Player.getRSPlayer().isInCombat() && !nearest.isInCombat()) {
            randomness = 1 + General.random(1, 99);
            if (nearest.isOnScreen()) {
                if ((randomness > 50)) {
                    nearest.click("Attack");
                    sleep(1500, 2250);
                }
                else {
                    Mouse.click(nearest.getModel().getTriangles()[0].getBounds().getLocation(), 1);
                    sleep(1500, 2250);
                }
            } else {
                Camera.turnToTile(nearest.getPosition());
            }
        } else if (Player.getPosition() != startTile) {
            Walking.walkTo(startTile);
            sleep(600, 940);

        }

    }
}

Sorry, I didn't notice the code quote

Share this post


Link to post
Share on other sites

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.