View Full Version : Need with java (related to RSBOT.)


syberium
02-09-2009, 08:12 AM
Hey I'm working on a very fast fighting script for rock crabs. I have it currently running faster than most humans, But there is one huge problem. The script consistently returns null pointers when there is no other players around, and sometimes but rarely when players are around. I don't quite understand the main functions of rsbot such as " return new RSPlayer(Bot.getClient().getPlayerArray()[index]);"

not sure what that really means, have a basic idea but not enough to do anything with. So I would like somebody to turn these functions from something that returns a null value, to a boolean. I find when they return booleans i dont get those errors because they are not returning null values..



public RSCharacter getInteracting() {
int interact = c.getInteracting();
if (interact == -1) {
return null;
}
if (interact < 32767) {
return new RSNPC(Bot.getClient().getNPCArray()[interact]);
} else if (interact >= 32767) {
int index = (interact - 32767);
if (index == Bot.getClient().getSelfInteracting()) {
index = 2047;
}
return new RSPlayer(Bot.getClient().getPlayerArray()[index]);
}
return null;
}

public boolean isInteractingWithLocalPlayer(){
return (c.getInteracting() - 32768) == Bot.getClient().getSelfInteracting();
}

ian.
02-09-2009, 08:14 AM
probably would be best to ask on rsbot forums? :o

syberium
02-09-2009, 08:16 AM
I did, just asking on multiple places. Because the root of this problem is java related not rsbot related.

Method
02-09-2009, 01:15 PM
You don't need to modify the method, just check to see if the object is null. If so, don't use any of the methods associated with it and try to get a new one.