if (cmd.length < 2) {
Under that you would have to make a method for it to go from 1-99. Trying to think of a way you can do it
|
I want to limit this command for players to not be able to give them a title past 100.
Like it not give them a title past ::title 99Code:if (cmd[0].equals("title")) { if (cmd.length < 2) { player.getPackets().sendGameMessage("Use: ::title id"); return true; } try { player.getAppearence().setTitle(Integer.valueOf(cmd[1])); } catch (NumberFormatException e) { player.getPackets().sendGameMessage("Use: ::title id"); } return true; }
How would I set this up
I have an interface for it also, this is just for super donors to be able to set their own command at any time, I just don't want them setting theirs to owner,admin,dicer and a couple other titles at 100+
Nevermind. I just set the owner titles and stuff to a ridiculously high number
Do you even know basics of programming?
Code:if (cmd[0].equals("title")) { try { int titleIdx = Integer.valueOf(cmd[1]); } catch (NumberFormatException e) { player.getPackets().sendGameMessage("Use: ::title id"); } if (cmd.length < 2) { player.getPackets().sendGameMessage("Use: ::title id"); return true; } if (titleIdx <= 100) { player.getAppearence().setTitle(Integer.valueOf(cmd[1])); } else { player.getPackets().sendGameMessage("You can not set a title with a higher value than 100"); return true; } return true; }
I have it set up like this:
that didn't work though:cCode:if (cmd[0].equals("title")) { if (cmd.length < 2) { int input = 0; Math.min(99, input); player.getPackets().sendGameMessage("Use: ::title id"); return true; } try { player.getAppearence().setTitle(Integer.valueOf(cmd[1])); } catch (NumberFormatException e) { player.getPackets().sendGameMessage("Use: ::title id"); } return true; }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |