Thread: Still able to tele in and out of dung even tho checks are made?

Results 1 to 4 of 4
  1. #1 Still able to tele in and out of dung even tho checks are made? 
    Banned
    Join Date
    Dec 2014
    Posts
    79
    Thanks given
    28
    Thanks received
    14
    Rep Power
    0
    Code:
    if (playerCommand.startsWith("xteleto")) {
    			String name = playerCommand.substring(8);
    			for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    				if (PlayerHandler.players[i] != null) {
    					if (PlayerHandler.players[i].playerName.equalsIgnoreCase(name)) {
    						Client c2 = (Client)PlayerHandler.players[i];
    						if(c2.InDung()) {
    								c.sendMessage("You cannot teleport to anyone who is in dung");
    								return;
    						} 
    						c.getPA().movePlayer(PlayerHandler.players[i].getX(), PlayerHandler.players[i].getY(), PlayerHandler.players[i].heightLevel);
    					}
    					}
    				}
    			}

    Still able to tele to and tele people out of dung, wondering where im going wrong
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Dec 2014
    Posts
    79
    Thanks given
    28
    Thanks received
    14
    Rep Power
    0
    Quote Originally Posted by packersfan84 View Post
    clearly you need to post the InDung method.

    it also might be an idea to make ur code a little more readable:
    Code:
    			if (playerCommand.startsWith("xteleto")) {
    				String name = playerCommand.substring(8);
    				for (Player player : PlayerHandler.players) {
    					if (player == null || !player.playerName.equalsIgnoreCase(name)) {
    						continue;
    					}
    					
    					Client c2 = (Client) player;
    					if (c2.InDung()) {
    						c.sendMessage("You cannot teleport to anyone who is in dung");
    						return;
    					} 
    					
    					c.getPA().movePlayer(player.getX(), player.getY(), player.heightLevel);
    				}
    			}

    Code:
    public boolean InDung() {
    				if(absX >= 2498 && absX <= 2565 && absY >= 9400 && absY <= 9480 ||
    				absX >= 2800 && absX <= 2900 && absY >= 9900 && absY <= 9999) {	
    			return true;
    		}
    		return false;
    	}
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2012
    Posts
    561
    Thanks given
    43
    Thanks received
    53
    Rep Power
    72
    Code:
    public boolean InDung() {
    	System.out.println("X:"+absX+" Y"+absY);
    		if(absX >= 2498 && absX <= 2565 && absY >= 9400 && absY <= 9480 ||
    			absX >= 2800 && absX <= 2900 && absY >= 9900 && absY <= 9999) {	
    		return true;
    	}
    	return false;
    }
    See what X and Y value it'll print out.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Dec 2011
    Posts
    793
    Thanks given
    204
    Thanks received
    176
    Rep Power
    173
    Quote Originally Posted by Lizard Squad View Post
    Code:
    public boolean InDung() {
    				if(absX >= 2498 && absX <= 2565 && absY >= 9400 && absY <= 9480 ||
    				absX >= 2800 && absX <= 2900 && absY >= 9900 && absY <= 9999) {	
    			return true;
    		}
    		return false;
    	}
    Add a System.out.println() that will print the result of that boolean, then you can see if it's returning correctly.
    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: 5
    Last Post: 10-15-2013, 04:08 PM
  2. how to make players not able to tele in combat
    By OodlesOfNoodles in forum Help
    Replies: 2
    Last Post: 12-16-2011, 07:25 PM
  3. Replies: 4
    Last Post: 08-03-2011, 11:47 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •