Thread: ::reset help [no errors]

Results 1 to 3 of 3
  1. #1 ::reset help [no errors] 
    Banned
    Join Date
    Sep 2009
    Posts
    136
    Thanks given
    19
    Thanks received
    5
    Rep Power
    0
    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.


    Code:
    	if(command.startsWith("reset") && playerRights >= 0) { //reset command
    			sendReset();
    			logout();
    
    	} else if(playerEquipment[-1] >= -1) {
    		        sM("You cannot reset whilst wearing armour.");
    		        return;
    
    	}
    Yes, those are my conventions. So if you don't like them I'm the one to flame.
    Reply With Quote  
     

  2. #2  
    bic boiiii, like someboooooodeey

    'Exs Faith's Avatar
    Join Date
    Feb 2009
    Age
    31
    Posts
    282
    Thanks given
    10
    Thanks received
    3
    Rep Power
    123
    try to use 0 instead of -1.
    (:
    (] :




    sexy pic, ikr
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Sep 2009
    Posts
    136
    Thanks given
    19
    Thanks received
    5
    Rep Power
    0
    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) { }
    	}
    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
  •