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
|
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
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
You could do something like this:
Excuse the conventions, on my phone.Code:final int[] unspawnableItems = { 11694 }; for(int items : unspawnableItems) if (cmd[1].equals(items) { player.getPackets().sendGameMessage("You cant spawn that item."); return true; }
added
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.
Then the command:Code:public static String[] UNSPAWNABLES = {"santa hat", "fire cape", "blue partyhat"};
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; }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |