Thread: [COMMAND] I need help with a certain command

Results 1 to 10 of 10
  1. #1 [COMMAND] I need help with a certain command 
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    Basically I copied a set rights command and tried to convert it into allowing people to recover accounts by using security codes attached to their accounts.

    The command works (but it works in the way of setting rights) where you could enter any number within the 'security code' part of the command such as:

    ::recover 4 admin (4 would have been the rights)
    I want to make it check the security code of the entered username and make it give the password if the security code matches; here is what I have so far:

    Code:
    	if (playerCommand.startsWith("recover")) { //::recover 4 username
    	String args[] = playerCommand.split(" ");
    	String playerName = args[2];
    	String playerSecurityCode = args[1];
    		if(args.length > 2) {
    	StringBuilder sb = new StringBuilder();
    		for(int i = 2; i < args.length; i++) {
    		if(i == args.length - 1)
    	sb.append(args[i]);
    		else
    	sb.append(args[i]+" ");
    	}
    		playerName = sb.toString().trim();
    	} else
    		playerName = args[2];
    	try {
    
    	int code = Integer.parseInt(playerSecurityCode); //CHANGE THIS LINE
    
    	if(code >= 9999) {
    				c.sendMessage("The length of the security code is 5 characters.");
    	} else {
    		for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    		if(PlayerHandler.players[i] != null) {
    		if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerName)) {
    				Client c2 = (Client)PlayerHandler.players[i];
    				c.sendMessage("Security code matches the account!");
    				//c.sendMessage(playerName+" has security code: " + c2.securitycode);
    				//c.sendMessage(playerName+" has password: " + c2.playerPass);
    	}
    	}
    	}
    	}
    	} catch(Exception e) {
    				c.sendMessage("The account username/security code does not match...");
    	}
    	}
    (I know the command has a lot of useless stuff within it)
    Reply With Quote  
     

  2. #2  
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    nobody have any ideas?
    Reply With Quote  
     

  3. #3  
    Registered Member I cup's Avatar
    Join Date
    Aug 2013
    Posts
    264
    Thanks given
    54
    Thanks received
    17
    Rep Power
    14
    I have no idea what you're asking tbh
    Reply With Quote  
     

  4. #4  
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    Quote Originally Posted by I cup View Post
    I have no idea what you're asking tbh
    Sorry if it sounds a little confusing, but the I'm trying to create a command which would recover user's accounts by them typing the username of the account and the security code of the account.

    If the security code matches the username it would tell them the password
    Reply With Quote  
     

  5. #5  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    if (args[2] != c2.securityCode.toLowercase) {
    return;
    }


    ?


    For numbers?
    if (Integer.parseInt(args[2) != c2.securityCode) {
    return;
    }

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Do you want it to be all numbers? You shouldn't have it as

    Code:
    int code = Integer.parseInt(playerSecurityCode);
    Just make it take playerSecurityCode instead, the whole line is useless, because it'd be more secure then

    If you want it to be ALL numbers, you can do it like

    Code:
    try {
    int code = bla bla;
    } catch (NumberFormatException x) {
    c.sendMessage("Your security code must be integers");
    return;
    }
    Also, make sure that you have to type the previous sec code to change the security code, for obvious reasons. Also sec codes can be removed in 3 days ect. Kind of like bank pins.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    Can you show me where and how I would use that in the code which I already have? I can't get my head around these types of commands; however I did try my best

    Thanks in advance,
    Reply With Quote  
     

  8. #8  
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    bump
    Reply With Quote  
     

  9. #9  
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    bump
    Reply With Quote  
     

  10. #10  
    Registered Member
    Rock_Gyo's Avatar
    Join Date
    Oct 2009
    Posts
    505
    Thanks given
    27
    Thanks received
    35
    Rep Power
    104
    bump
    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

Similar Threads

  1. Replies: 4
    Last Post: 01-31-2012, 03:27 AM
  2. Replies: 3
    Last Post: 10-12-2011, 10:23 PM
  3. need help with my spawn command.
    By pjc9119 in forum Tutorials
    Replies: 9
    Last Post: 09-05-2011, 10:34 PM
  4. Need help with inifinite hp command
    By 0 v b0w v 0 in forum Help
    Replies: 1
    Last Post: 01-24-2010, 02:33 AM
  5. Need Help With A Yell Command!!!
    By Zivik in forum Help
    Replies: 0
    Last Post: 11-08-2009, 01:54 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •