Will work.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>."); } }
|
:ICKUP COMMAND! REP++
I am helping a mate with a :: pickup server.
But the command doesent work.
heres the command methed.
Try'd - && playerRights > 0) { to 6 and wouldent work still.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"); } } }
Please help rep++ for helping.
Will work.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>."); } }
I think "args.length == 3" is referring to 4 tokens.
example -Try changing it to "== 2" and see what it does.Code:::pickup 995 100 ?? ^ ^ ^ ^ 0 1 2 3
No look this should work
i copied that from my sourceCode: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"); } } }
Mine would work just fine and its simpler. Your's is doing double the work.
You can figure out the logic. At least I hope.Code:int newItemID = Integer.parseInt(args[1]); int newItemAmount = Integer.parseInt(args[2]);
Code:addItem(Integer.valueOf(args[1]), Integer.valueOf(args[2]));
Yea, sorry about that.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |