try to use 0 instead of -1.
|
Hey guys I'm making a reset command for my server so it sets all of the stats back to 1 (except for hp it goes to 10). The problem I'm having is I don't want people to be wearing armour while they do the command. The reason is because people could put on full bandos and then do the reset and be level 3 with bandos So I tried to make it where you can't wear armour while you execute the command.
There are no compiling errors, the only problem I have is that it only does the first if statement. Also I think I might have the numbers in red mixed up with what they really should be. Like -1 for wearing armour might be 1, I just don't know.
Yes, those are my conventions. So if you don't like them I'm the one to flame.Code:if(command.startsWith("reset") && playerRights >= 0) { //reset command sendReset(); logout(); } else if(playerEquipment[-1] >= -1) { sM("You cannot reset whilst wearing armour."); return; }
Fixed. Obviously I have tried playing with the numbers...
Winning code
Code:if (command.equalsIgnoreCase("reset")) { //reset command try { boolean canReset = false; for (int i = 0; i < playerEquipment.length; i++) { if (playerEquipment[i] < 0) { canReset = true; } else if (playerEquipment[i] > -1) { canReset = false; break; } } if (canReset) { sendReset(); logout(); } else { sM("You cannot reset whilst wearing armour."); } } catch (Exception e) { } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |