Thread: Help with error?

Results 1 to 6 of 6
  1. #1 Help with error? 
    Registered Member
    Join Date
    Nov 2011
    Posts
    47
    Thanks given
    3
    Thanks received
    1
    Rep Power
    11
    Reply With Quote  
     

  2. #2  
    Registered Member Recursion's Avatar
    Join Date
    Feb 2010
    Posts
    638
    Thanks given
    0
    Thanks received
    29
    Rep Power
    41
    Looks like you're checking the item name and then comparing it to an item id after a player uses what i'm guessing to be a pickup command?

    Why not just grab the id of the item they are trying to pickup (the item id they typed), and then compare it to the RESTRICTED_PICKUP_ITEMS? If they're equal and the player isn't an admin, send the message saying they must be an admin to pick that item up and then return the statement.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2011
    Posts
    47
    Thanks given
    3
    Thanks received
    1
    Rep Power
    11
    Thats what i tried i think
    Code:
    		if (playerCommand.startsWith("item")) {
    				if (c.inWild())
    					return;
    				String[] args = playerCommand.split(" ");
    				int newItemID = Integer.parseInt(args[1]);
    				int newItemAmount = Integer.parseInt(args[2]);
    				if (args.length == 3) {
    					if ((newItemID <= 21000) && (newItemID >= 0)) {
    						for (int i = 0; i < Config.RESTRICTED_PICKUP_ITEMS.length; i++) {
    							if (c.getItems().getItemName(newItemID).toLowerCase().contains(Config.RESTRICTED_PICKUP_ITEMS[i]) && c.playerRights != 3) {
    								c.sendMessage("This item can not be obtained through spawning, earn it a different way.");
    								return;
    							}
    						}
    						c.getItems().addItem(newItemID, newItemAmount);
    			}
    			}
    			}
    Reply With Quote  
     

  4. #4  
    Registered Member
    Nando's Avatar
    Join Date
    Feb 2009
    Age
    29
    Posts
    3,517
    Thanks given
    2,439
    Thanks received
    1,108
    Rep Power
    5000
    Code:
    if (playerCommand.startsWith("item")) {
    				if (c.inWild())
    					return;
    				String[] args = playerCommand.split(" ");
    				int newItemID = Integer.parseInt(args[1]);
    				int newItemAmount = Integer.parseInt(args[2]);
    				if (args.length == 3) {
    					if ((newItemID <= 21000) && (newItemID >= 0)) {
    						for (int i = 0; i < Config.RESTRICTED_PICKUP_ITEMS.length; i++) {
    							if (c.getItems().getItemName(newItemID).toLowerCase().contains(c.getItems().getItemName(Config.RESTRICTED_PICKUP_ITEMS[i]).toLowerCase()) && c.playerRights != 3) {
    								c.sendMessage("This item can not be obtained through spawning, earn it a different way.");
    								return;
    							}
    						}
    						c.getItems().addItem(newItemID, newItemAmount);
    			}
    			}
    			}
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Nov 2011
    Posts
    47
    Thanks given
    3
    Thanks received
    1
    Rep Power
    11
    thanks nando your a beast lol
    Reply With Quote  
     

  6. #6  
    Registered Member Recursion's Avatar
    Join Date
    Feb 2010
    Posts
    638
    Thanks given
    0
    Thanks received
    29
    Rep Power
    41
    Here, try this. It should work.

    The part I changed is in red..

    Code:
    	if (playerCommand.startsWith("item")) {
    		if (c.inWild())
    	return;
    		String[] args = playerCommand.split(" ");
    			int newItemID = Integer.parseInt(args[1]);
    			int newItemAmount = Integer.parseInt(args[2]);
    				if (args.length == 3) {
    					if ((newItemID <= 21000) && (newItemID >= 0)) {
    						for (int i = 0; i < Config.RESTRICTED_PICKUP_ITEMS.length; i++) {
    							if ((newItemID == i) && c.playerRights != 3) {
    								c.sendMessage("This item can not be obtained through spawning, earn it a different way.");
    								return;
    							}
    						}
    						c.getItems().addItem(newItemID, newItemAmount);
    				}
    		}
    	}
    Let me know if that worked or not.

    Edit: Sorry about that, didn't realize Nando already posted, was in the middle of being a victim of a ddos attack.
    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. ERROR K4rn4ge 634 model header error
    By DeeJay in forum Help
    Replies: 0
    Last Post: 03-17-2012, 03:17 PM
  2. Replies: 2
    Last Post: 01-26-2012, 03:38 PM
  3. Replies: 9
    Last Post: 10-20-2011, 07:52 AM
  4. Replies: 6
    Last Post: 09-15-2010, 04:20 PM
  5. Replies: 6
    Last Post: 05-01-2010, 05:18 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
  •