Elvarg base, getting ladders to work..
Somewhere on the forums I found the following:
Code:
case LADDER:
player.getMovementQueue().reset();
player.performAnimation(new Animation(828)); // Perform animation
if((Math.abs(player.getPosition().getX() - x) <= 1) || //Check if player is close to ladder.
(Math.abs(player.getPosition().getY() - y) <= 1)){
TaskManager.submit(new Task(2) { //After 2 ticks, move up the ladder.
@Override
public void execute() {
player.getPacketSender().sendMessage("You climb up the ladder.");
player.moveTo(new Position(player.getPosition().getX(), player.getPosition().getY(), 2));
player.getMovementQueue().reset();
stop(); // Stop task
}
});
}else {
player.getPacketSender().sendMessage("I can't reach that!"); //Player is not close to ladder
//And cannot perform the action.
}
break;
But this doesn't seem to be working the way I wanted.
I then made this(which might be shitty code, I am quite new):
Code:
case LADDER:
player.performAnimation(new Animation(828));
if((Math.abs(player.getPosition().getX() - x) <= 1) || //Check if player is close to ladder.
(Math.abs(player.getPosition().getY() - y) <= 1));
player.getClickDelay().reset();
TaskManager.submit(new Task(2) {
public void execute() {
player.moveTo(new Position(2214, 3802, 1));
player.getPacketSender().sendMessage("You climb up a ladder.");
stop();
}
});
This works fine, but ofcourse only works for 1 ladder of the same id. (same for the first code I showed btw)
How can I change this so that it only affects a specific ladder? (so for example by adding the ladders coordinates as a reference)
The codes are pretty much the same, I just played around with the first one to my liking.. Like I said, I am not the best coder.