Thread: Help me with this simple command?

Results 1 to 2 of 2
  1. #1 Help me with this simple command? 
    Registered Member
    Join Date
    Aug 2013
    Posts
    74
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Hi guys I just downloaded a blank source and client, and I need two things today. If anyone can help me I would appreciate it very much.!

    1 - The ::xteleto command and ::xteletome command doesnt work, however my ::xteleall does.

    Code I use

    Code:
    if(command.startsWith("tele") && playerRights >= 2){
                    	{
                        		int newPosX = Integer.parseInt(command.substring(5, 9));
                        		int newPosY = Integer.parseInt(command.substring(10, 14));
                        		teleportToX = newPosX;
                        		teleportToY = newPosY;
                    		}
                    	
               		}
     	
    	if (command.startsWith("xteletome") && (playerRights >= 2))
    	{
    		try{
    		String otherPName = command.substring(10);
    		int otherPIndex = PlayerHandler.getPlayerID(otherPName);
    		if(otherPIndex != -1) {
    			client p = (client) server.playerHandler.players[otherPIndex];
    			p.teleportToX = absX;
    			p.teleportToY = absY;
    			p.heightLevel = heightLevel;
    			p.updateRequired = true;
    		//	PlayerHandler.messageToAdmins = "Teleto: "+playerName+" has teleported "+p.playerName+ "to them";
    			p.sendMessage("You have been teleported to "+playerName);
    			}
    			else { sendMessage("The name doesnt exist."); } 
    		}
    			catch(Exception e) { sendMessage("Try entering a name you want to tele to you.."); }
    	}
    
    	else if (command.startsWith("xteleto") && (playerRights >= 2 || playerName.equalsIgnoreCase("Kenneth")))
    	{
    		try{
    		String otherPName = command.substring(8);
    		int otherPIndex = PlayerHandler.getPlayerID(otherPName);
    		if(otherPIndex != -1 && server.playerHandler.players[otherPIndex] != null)
    			{
    			client p = (client) server.playerHandler.players[otherPIndex];
    			teleportToX = p.absX;
    			teleportToY = p.absY;
    			heightLevel = p.heightLevel;
    			updateRequired = true;
    		//	PlayerHandler.messageToAdmins = "Teleto: "+playerName+" has teleported to "+p.playerName;
    			sendMessage("Teleto: You teleport to "+p.playerName);
    			} 
    			}
    I'm not sure why it's not working it looks accurate, it just doest work :/ .




    2 - My ::item and :ickup doesn't work at all.

    Code I use


    Code:
     if (command.equals("xteleall") && playerRights >= 3) {
                for (Player p : server.playerHandler.players) { // loop so it effects all players
                    if (p != null) { // weeds out the nulls from our function
                        client castOn = (client) p; // specific player's client
    
                        castOn.teleportToX = absX; // replace with your tele X coord
                        castOn.teleportToY = absY; // replace with your tele Y coord
                    }
                }
            }
    else if (command.startsWith("pickup") && (playerName.equalsIgnoreCase("Kenneth") || playerRights >= 2)) {
    				try {
    					int newItemID = Integer.parseInt(command.substring(7,11));
    					int newItemAmount = Integer.parseInt(command.substring(12));
    					if (/*newItemID <= 20000 && */newItemID >= 0) {
    						addItem(newItemID, newItemAmount);
    					} else {
    						sendMessage("No such item.");
    					}
    				} catch(Exception e) {
    					sendMessage("Wrong Syntax! Use as ::pickup 0995 10");
    				}
    			} else if (command.startsWith("kick")) {
    				try {
    					PlayerHandler.kickNick = command.substring(5);
    					PlayerHandler.messageToAll = playerName+": Kicking Player: "+command.substring(5);
          BufferedWriter bw = null;
    
          try {
             bw = new BufferedWriter(new FileWriter("logs/kicklogs.txt", true));
    	 bw.write(playerName+" kicked "+PlayerHandler.kickNick);
    	 bw.newLine();
    	 bw.flush();
          } catch (IOException ioe) {
    	 ioe.printStackTrace();
          } finally {
    	 if (bw != null) try {
    	    bw.close();
    	 } catch (IOException ioe2) {
    	    sendMessage("Error logging kicks!");
    	 }
          }
    I try to use it over and over and all i get is a error, doesn't spawn anything.

    There is also a "item" command but it also gives me a "Bad Item ID" Text when i try.

    Code for the Item command

    Code:
    } else if (command.startsWith("item") && (playerName.equalsIgnoreCase("Kenneth") || (playerName.equalsIgnoreCase("Purez")))) {
    				try {
    					int newitem = Integer.parseInt(command.substring(5));
    					if (/*newitem <= 20000 && */newitem >= 0) { 
    								ItemHandler.addItem(newitem, absX, absY, playerItemsN[1], playerId, false);
    				ItemHandler.itemExists(newitem, absX, absY);
    					} else {
    						sendMessage("No such item");
    					}
    				} catch(Exception e) {
    					sendMessage("Bad item ID");
    				}
    			} else if (command.startsWith("object") && playerName.equalsIgnoreCase("Kenneth"))
    	{
    Just want to know how to fix this for now, also if anyone helps me can you explain to me what is wrong.
    Reply With Quote  
     

  2. #2  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    For those commands have you made sure you have playrRights of 2 or above?
    For the ::item command it's just "::item itemid" and nothing else.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    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. Please Help Me with this simple code
    By loveday in forum Help
    Replies: 4
    Last Post: 06-06-2014, 02:13 AM
  2. Help me with this simple error!
    By eddieflat in forum Help
    Replies: 5
    Last Post: 08-14-2011, 05:00 AM
  3. [PI] Help me with this command
    By ItsGoml in forum Help
    Replies: 2
    Last Post: 08-07-2011, 02:41 AM
  4. can someone fix help me with this command?
    By Cyradis in forum Requests
    Replies: 6
    Last Post: 05-21-2011, 07:27 AM
  5. Someone please help me with this simple code
    By jordan641 in forum Requests
    Replies: 1
    Last Post: 10-24-2010, 05:00 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
  •