Jump to content

My first cow killer script help.


Gengar

Recommended Posts

Hey Guys,

I was following Swizzbeat's youtube video and the written guide for two example scripts and whenever I put them into the OSBot folder it will not play the script.  The mouse cursor will simply sit there and not interact with anything even though I followed his guide perfectly.  Can anyone help me?  I will post my code below for my cow killer script to see if anyone can help.

package CowKillerProject;

import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.model.Entity;

@ScriptManifest(author = "Gengar", info = "Cow Killer", name = "CowKiller .1", version = 0.1)

public class cowkiller extends Script{
	final String Cow_Name = "cow";
	public void onStart(){
		log("Start at cows!");	
	}
	public int onLoop() throws InterruptedException {
		Entity cow = closestAttackableNPCForName("Cow_Name");
	
	if (cow !=null){
	if (!client.getMyPlayer().isUnderAttack())
		if (cow.isVisible()){
		cow.interact("Attack");
	}else{
		client.moveCameraToEntity(cow);
	}
		
	}
	return 50;
}
	public void onExit(){
		log("Thank you for using my script!");
	}
}
Link to comment
Share on other sites

Why does everyone think that's my video? I explicitly state in the line before it that @H0ppy made it O_o

 

And no offence but I suggest learning Java before scripting. The error you made is extremely easy to spot (look at the argument your passing to the closest...NPC() method).

Edited by Swizzbeat
  • Like 1
Link to comment
Share on other sites

Entity cow = closestAttackableNPCForName("Cow_Name");

 

should be:

 

Entity cow = closestAttackableNPCForName(Cow_Name);

(No quotation marks)

 

Quotation marks are for strings. If you want to use a variable you don't use quotation marks.

 

Also you should look up some Java Naming Conventions:

http://en.wikipedia.org/wiki/Naming_convention_(programming)#Java

 

Your class should be CowKiller. It's not something that affects your code but it is something that makes your code more readable.

Edited by Artemis
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...