Thread: [PI] Converting tele timer in process to event/task

Results 1 to 3 of 3
  1. #1 [PI] Converting tele timer in process to event/task 
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    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.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Cadillac's Avatar
    Join Date
    Jul 2014
    Age
    6
    Posts
    334
    Thanks given
    0
    Thanks received
    228
    Rep Power
    951
    Well done. This is the proper execution of a cycle event. Repped. Still, I'd suggest ripping the worker system and using that instead from Asteria. It will be far more beneficial as it's queued and will not throw nullpointers.
    back at it.
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Donator

    Join Date
    Feb 2013
    Posts
    197
    Thanks given
    100
    Thanks received
    8
    Rep Power
    19
    awesome thanks
    Spoiler for massive sig:




    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 56
    Last Post: 09-18-2016, 07:19 AM
  2. Replies: 12
    Last Post: 10-29-2013, 09:08 PM
  3. [PI] Adding Tele's in mage tab [whit pic]
    By dutch helper in forum Help
    Replies: 10
    Last Post: 01-09-2011, 09:38 PM
  4. help convert process to event manager
    By jack24 in forum Help
    Replies: 22
    Last Post: 11-28-2009, 07:03 PM
  5. Converting Process() To Events
    By Enjoi in forum Tutorials
    Replies: 35
    Last Post: 07-13-2009, 01:33 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •