Code:
package server.event.impl;
import server.event.CycleEvent;
import server.event.CycleEventContainer;
import server.model.players.Client;
/**
* Handles the teletimer task while teleporting
* @author Karma
*
*/
public class TeleportingEvent extends CycleEvent {
/**
* Creates an instance of the client
*/
private Client client;
/**
* Constructs the class for the client
* @param client
* the client
*/
public TeleportingEvent(Client client) {
this.client = client;
}
@Override
public void execute(CycleEventContainer container) {
client.sendMessage(""+client.teleTimer);
if (client.teleTimer == 0) {
container.stop();
return;
}
if (client.teleTimer > 0) {
client.teleTimer--;
if (!client.isDead) {
if (client.teleTimer == 1 && client.newLocation > 0) {
client.teleTimer = 0;
client.getPA().changeLocation();
}
if (client.teleTimer == 5) {
client.teleTimer--;
client.getPA().processTeleport();
}
if (client.teleTimer == 9 && client.teleGfx > 0) {
client.teleTimer--;
client.gfx100(client.teleGfx);
}
}
}
}
@Override
public void stop() {
client.teleTimer = 0;
}
}
now just call
CycleEventHandler.getSingleton().addEvent(null, new TeleportingEvent(c), 1);
wherever you have teleTimer declared more than 0, but be smart about it. example.
Code:
public void startTeleport(int x, int y, int height, String teleportType) {
if (teleportType.equalsIgnoreCase("dung") && c.inWild()) {
c.sM("Really?");
return;
}
if (c.inWild() && c.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) {
c.sM("You can't teleport above level "
+ Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness.");
return;
}
if (c.duelStatus == 5) {
c.sM("You can't teleport during a duel!");
return;
}
if (c.inPits || c.viewingOrb || inPitsWait()
|| c.championWar.inWaitRoom() || c.championWar.team != 0) {
c.sM("You can't teleport in here!");
return;
}
if (c.cantWalk) {
return;
}
if (c.getFog().inFog(c)) {
c.sM("You can not teleport out of FOG");
return;
}
if (c.inGWD()) {
ResetGWKC();
}
if (c.inJail() && c.Jail == true) {
c.sM("You can't teleport out of prison idiot!");
return;
}
if (c.Jail == true) {
c.sM("You can't teleport out until you are dealt with!");
return;
}
if (c.inWarriorG() && c.heightLevel == 2) {
c.sM("You can't teleport out of Warrior Guild!");
return;
}
if (c.inPcGame()) {
c.sM("What are you trying to do? Protect the Void Knight!");
return;
}
if (c.inRFD()) {
c.sM("You can't teleport out of this minigame!");
return;
}
if (c.inFunPk() && c.underAttackBy > 0) {
c.sM("You can not teleport in fun pk!");
return;
}
if (c.inFightCaves()) {
c.sM("You can't teleport out of this minigame!");
return;
}
if (c.inWild() && c.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) {
c.sM("You can't teleport above level "
+ Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness.");
return;
}
if (c.inDungeoneering && c.playerRights != 3) {
c.sM("Aren't you a smart guy?");
return;
}
if (System.currentTimeMillis() - c.teleBlockDelay < c.teleBlockLength) {
c.sM("You are teleblocked and can't teleport.");
return;
}
if (c.inWild()) {
if (!c.getItems().playerHasItem(563, 5)) {
c.sM("You need 5 law runes to teleport when in the wilderness.");
return;
} else {
c.getItems().deleteItem(563, 5);
}
}
if (!c.isDead && c.teleTimer == 0 && c.respawnTimer == -6) {
if (c.playerIndex > 0 || c.npcIndex > 0)
c.getCombat().resetPlayerAttack();
c.stopMovement();
EarningPotential.checkTeleport(c);
removeAllWindows();
c.teleX = x;
c.teleY = y;
c.npcIndex = 0;
c.playerIndex = 0;
c.faceUpdate(0);
c.teleHeight = height;
if (teleportType.equalsIgnoreCase("modern")) {
c.startAnimation(8939);
c.teleTimer = 9;
c.gfx0(1576);
c.teleEndAnimation = 8941;
}
if (teleportType.equalsIgnoreCase("abyss")) {
c.startAnimation(1816);
c.teleTimer = 9;
c.gfx0(342);
c.teleEndAnimation = 8941;
}
if (teleportType.equalsIgnoreCase("ancient")) {
c.startAnimation(9599);
c.teleGfx = 0;
c.teleTimer = 11;
c.teleEndAnimation = 8941;
c.gfx0(1681);
}
if (teleportType.equalsIgnoreCase("dung")) {
c.startAnimation(13288);
// c.teleGfx = 2516;
c.teleTimer = 6;
c.teleEndAnimation = 13285;
c.gfx0(2517);
}
if (teleportType.equalsIgnoreCase("fog")) {
c.startAnimation(9012);
c.teleTimer = 6;
c.teleEndAnimation = 9018;
}
CycleEventHandler.getSingleton().addEvent(null, new TeleportingEvent(c), 1);
}
}
ignore the shit code.