Thread: Errors when I made more items unspawnable.

Results 1 to 6 of 6
  1. #1 Errors when I made more items unspawnable. 
    Registered Member
    Join Date
    Jul 2013
    Posts
    150
    Thanks given
    3
    Thanks received
    4
    Rep Power
    13
    Hello,

    I started with a 667-718 - Yes I know it's better to start with a 317 xD
    I'm new @ coding, when I saw this : Screenshot by Lightshot
    I thought I just have to keep adding:

    }
    if (cmd[1].equalsIgnoreCase("")) {
    player.getPackets().sendGameMessage("You cant spawn that item.");
    return true;
    }


    Guess what? It gave me 100 errors I added like 15 or so.
    Compiler : Screenshot by Lightshot.
    I really hope someone can me help out.
    Skype Yellowguy6
    Reply With Quote  
     

  2. #2  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Here's a block statement

    {

    }

    You always have an opening bracket then your statement ten you close it. You're adding an extra closing bracket above each one
    Reply With Quote  
     

  3. #3  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    You could do something like this:

    Code:
    final int[] unspawnableItems = { 11694 };
    
    for(int items : unspawnableItems)
    if (cmd[1].equals(items) {
    player.getPackets().sendGameMessage("You cant spawn that item.");
    return true;
    }
    Excuse the conventions, on my phone.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2013
    Posts
    150
    Thanks given
    3
    Thanks received
    4
    Rep Power
    13
    Quote Originally Posted by Visitor View Post
    You could do something like this:

    Code:
    final int[] unspawnableItems = { 11694 };
    
    for(int items : unspawnableItems)
    if (cmd[1].equals(items) {
    player.getPackets().sendGameMessage("You cant spawn that item.");
    return true;
    }
    Excuse the conventions, on my phone.

    Thanks for answering.
    I'm clueless i'll wait on someone that can Teamviewer me and explain me what I did faulth and why.
    And how to fix it.
    Thanks anyway
    Reply With Quote  
     

  5. #5  
    Banned
    Join Date
    Feb 2014
    Posts
    348
    Thanks given
    18
    Thanks received
    17
    Rep Power
    0
    added
    Reply With Quote  
     

  6. #6  
    Registered Member _Andy's Avatar
    Join Date
    May 2013
    Age
    28
    Posts
    643
    Thanks given
    224
    Thanks received
    111
    Rep Power
    4
    Firstly, it's not a better idea to start with 317. I never did and i'm glad.
    put this in your Settings.java
    Here you can add any items you don't want to be spawned, by name.
    Code:
    public static String[] UNSPAWNABLES = {"santa hat", "fire cape", "blue partyhat"};
    Then the command:
    Code:
    if (cmd[0].equalsIgnoreCase("item") {
    				if (cmd.length < 2) {
    					player.getPackets().sendGameMessage(
    							"Use: ::item id (optional:amount)");
    					return true;
    				}
    				try {
    					if (!player.canSpawn()) {
    						player.getPackets().sendGameMessage(
    								"You can't spawn while you're in this area.");
    						return true;
    					}
    					int itemId = Integer.valueOf(cmd[1]);
    					ItemDefinitions defs = ItemDefinitions
    							.getItemDefinitions(itemId);
    					String name = defs == null ? "" : defs.getName()
    							.toLowerCase();
    					for (String string : Settings.UNSPAWNABLES) {
    						if (name.toLowerCase().equals(string)) {
    							player.getPackets().sendGameMessage("You can't spawn this item.");
    							return true;
    						}
    					}
    					player.getInventory().addItem(itemId,
    							cmd.length >= 3 ? Integer.valueOf(cmd[2]) : 1);
    				} catch (NumberFormatException e) {
    					player.getPackets().sendGameMessage(
    							"Use: ::item id (optional:amount)");
    				}
    				return true;
    }
    quit
    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. [Galkon]Error when picking up some item
    By zivkovic in forum Help
    Replies: 26
    Last Post: 03-21-2011, 07:48 AM
  2. [PI]Error when trying to wear item
    By zivkovic in forum Help
    Replies: 2
    Last Post: 12-22-2010, 10:05 PM
  3. Error when adding new item
    By brambelg in forum Help
    Replies: 1
    Last Post: 02-07-2009, 12:04 PM
  4. Replies: 25
    Last Post: 07-27-2008, 11:46 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
  •