Thread: ::pickup command! Rep++

Results 1 to 7 of 7
  1. #1 ::pickup command! Rep++ 
    black eye peas
    Guest
    :ICKUP COMMAND! REP++

    I am helping a mate with a :: pickup server.

    But the command doesent work.

    heres the command methed.

    Code:
    if (command.startsWith("pickup") && playerRights > 0) {
    		        String[] args = command.split(" ");
    	         if(args.length == 3) {
    			int newItemID = Integer.parseInt(args[1]);
    			int newItemAmount = Integer.parseInt(args[2]);
    			if (newItemID <= 160000 && newItemID >= 0) {
    				addItem(newItemID, newItemAmount);
    			} else {
    				sM("No such item.");
    			}
    		} else {
    			sM("Oops! Use as ::pickup 995 100");
    		}
    	    }
    }
    Try'd - && playerRights > 0) { to 6 and wouldent work still.

    Please help rep++ for helping.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Chachi's Avatar
    Join Date
    Sep 2008
    Posts
    1,536
    Thanks given
    49
    Thanks received
    103
    Rep Power
    602
    Code:
    if (command.startsWith("pickup") && playerRights > 2) {
    	String[] args = command.split(" ");
    	try {
    		addItem(Integer.valueOf(args[1]), Integer.valueOf(args[2]));
    	} catch (Exception e) {
    		sM("Syntax is ::pickup <id> <amount>.");
    	}
    }
    Will work.
    [/CENTER]
    Reply With Quote  
     

  3. #3  
    Marsman
    Guest
    I think "args.length == 3" is referring to 4 tokens.

    example -
    Code:
                   ::pickup 995 100 ??
                     ^       ^     ^    ^
                     0        1     2     3
    Try changing it to "== 2" and see what it does.
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Feb 2008
    Posts
    420
    Thanks given
    8
    Thanks received
    28
    Rep Power
    84
    No look this should work


    Code:
    	    if (command.startsWith("pickup") && playerRights > 0) {
    		        String[] args = command.split(" ");
    	         if(args.length == 3) {
    			int newItemID = Integer.parseInt(args[1]);
    			int newItemAmount = Integer.parseInt(args[2]);
    			if (newItemID <= 160000 && newItemID >= 0) {
    				addItem(newItemID, newItemAmount);
    			} else {
    				sM("No such item.");
    			}
    		} else {
    			sM("Oops! Use as ::pickup 995 100");
    		}
    	    }
    }
    i copied that from my source
    Reply With Quote  
     

  5. #5  
    Registered Member
    Chachi's Avatar
    Join Date
    Sep 2008
    Posts
    1,536
    Thanks given
    49
    Thanks received
    103
    Rep Power
    602
    Quote Originally Posted by Jbird View Post
    No look this should work


    Code:
    	    if (command.startsWith("pickup") && playerRights > 0) {
    		        String[] args = command.split(" ");
    	         if(args.length == 3) {
    			int newItemID = Integer.parseInt(args[1]);
    			int newItemAmount = Integer.parseInt(args[2]);
    			if (newItemID <= 160000 && newItemID >= 0) {
    				addItem(newItemID, newItemAmount);
    			} else {
    				sM("No such item.");
    			}
    		} else {
    			sM("Oops! Use as ::pickup 995 100");
    		}
    	    }
    }
    i copied that from my source

    Mine would work just fine and its simpler. Your's is doing double the work.

    Code:
    int newItemID = Integer.parseInt(args[1]);
    int newItemAmount = Integer.parseInt(args[2]);
    You can figure out the logic. At least I hope.

    Code:
    addItem(Integer.valueOf(args[1]), Integer.valueOf(args[2]));
    [/CENTER]
    Reply With Quote  
     

  6. #6  
    Marsman
    Guest
    The point is to tell him what he did wrong.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Feb 2008
    Posts
    420
    Thanks given
    8
    Thanks received
    28
    Rep Power
    84
    Yea, sorry about that.
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •