Thread: Item command problem

Results 1 to 5 of 5
  1. #1 Item command problem 
    Registered Member
    Join Date
    Sep 2013
    Posts
    273
    Thanks given
    45
    Thanks received
    50
    Rep Power
    45
    I can spawn any item as long as the amount is 0 at the end.

    Ex: ::item 14484 0 = claw spawn. Anyone can do it.

    Code:
    if (playerCommand.startsWith("item")) { 
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int [] unspawnables = {13362,13358,13360,13355,13354,13352};
    				
    						int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    					int itemID = Integer.parseInt(args[1]);
    					for(int i : unspawnables) {
    						if(c.playerRights <= 2) {
    							if(itemID == i) {
    								c.sendMessage("You cannot spawn this item.");
    								return;
    							}
    						}
    					}
    					if ((newItemID <= 30000) && (newItemID >= 0)) {
    						c.getItems().addItem(newItemID, newItemAmount);
    						//System.out.println("Spawned: " + newItemID + " by: " + c.playerName);
    						c.sendMessage("Spawned: " + newItemID + "");
    					} else {
    						c.sendMessage("That item ID does not exist.");
    					}
    				} else {
    					c.sendMessage("Wrong command or doesn't exist");
    				}
    				} catch (Exception e) {
    				
    				}
    			}
    How do I fix it?
    Reply With Quote  
     

  2. #2  
    Registered Member I cup's Avatar
    Join Date
    Aug 2013
    Posts
    264
    Thanks given
    54
    Thanks received
    17
    Rep Power
    14
    I'm a bit confused on what your problem is, but I'll just assume.

    I'm guessing you want to make it so only the owner can spawn? Replace the first line with this:

    Code:
    if (playerCommand.startsWith("item") && c.playerRights >= 3) {
    The player rights at the end there specifies who can use this command.
    Reply With Quote  
     

  3. #3  
    Naughty Toys
    Toys's Avatar
    Join Date
    Sep 2013
    Posts
    201
    Thanks given
    21
    Thanks received
    9
    Rep Power
    37
    Code:
    if (playerCommand.startsWith("item") && c.playerName.equalsIgnoreCase("tom")) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						if ((newItemID <= 30000) && (newItemID >= 0)) {
    							c.getItems().addItem(newItemID, newItemAmount);		
    						} else {
    							c.sendMessage("No such item.");
    						}
    					} else {
    						c.sendMessage("Use as ::pickup 995 200");
    					}
    				} catch(Exception e) {
    					
    				}
    			}
    try using that. put your name in the name spot, if you want so it's ranked base add this as the first line
    Code:
    if (playerCommand.equals("item") && c.playerRights >= 3){
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    That's obviously not his problem.

    It seems like you don't even have 14484 in the array for unspawnables, so it lets you spawn them.

    Also, you can add

    Code:
    if (newItemAmount =< 0) {
    c.sendMessage("Please use a legitimate number");
    return;
    }
    After it gives newItemAmount a value
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Sep 2013
    Posts
    273
    Thanks given
    45
    Thanks received
    50
    Rep Power
    45
    I want players to be able to spawn. But they are able to spawn anything as long as they put a 0 for the item amount. I want to make it so you can't spawn anything if you input an amount of 0.
    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. [508] Item Commands (Easier Than ::item)
    By Zach11 in forum Tutorials
    Replies: 49
    Last Post: 09-17-2013, 02:40 AM
  2. Replies: 3
    Last Post: 11-21-2010, 01:13 PM
  3. item commaND HELP
    By `Lubricant in forum Tutorials
    Replies: 6
    Last Post: 08-03-2008, 09:11 PM
  4. REQ item commands
    By nameless762 in forum Requests
    Replies: 0
    Last Post: 07-20-2008, 05:33 PM
  5. [TUT] adding item commands [TUT]
    By blitz n dds in forum Tutorials
    Replies: 0
    Last Post: 02-08-2008, 04:36 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
  •