Thread: [Pi] Commands do not register 2-Word Names

Results 1 to 8 of 8
  1. #1 [Pi] Commands do not register 2-Word Names 
    Registered Member Skarlett's Avatar
    Join Date
    Apr 2013
    Posts
    405
    Thanks given
    47
    Thanks received
    7
    Rep Power
    13
    Most of my commands do not register if the player had two words in their username, any ideas?

    For instance:

    Code:
    if (playerCommand.startsWith("givetitle") && c.playerName.equalsIgnoreCase("Ain")) {
    				if (c.playerRights != 3)
    					return;
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int titleId = Integer.parseInt(args[1]);
    						String playerToGiveTitle = args[2];
    						for(int i = 0; i < PlayerHandler.players.length; i++) {
    							if(PlayerHandler.players[i] != null) {
    								if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToGiveTitle)) {
    									Client o = (Client)PlayerHandler.players[i];
    									c.sendMessage("You have given "+ Misc.optimizeText(o.playerName) +" a title.");
    									o.sendMessage("You have been give a title by "+ Misc.optimizeText(c.playerName) +".");
    									o.playerTitle = titleId;
    									o.getPA().requestUpdates();
    									return;
    								}
    							}
    						}
    					} else {
    						c.sendMessage("Wrong usage of this command!");
    					}
    				} catch (Exception e) {
    					c.sendMessage("Player must be offline.");
    				}
    			}
    ♡Lovvveeee♡
    Reply With Quote  
     

  2. #2  
    Project Drop-Zone Owner & The BLOOD Gang Always Banging RED


    Join Date
    May 2013
    Age
    28
    Posts
    2,992
    Thanks given
    5
    Thanks received
    937
    Rep Power
    183
    Works fine on mine >.> maybe because you might have to implement something else in a different file for it to have a title ? I have 2 spaces in my username and it works. Try re writing the command different format
    Reply With Quote  
     

  3. #3  
    Registered Member Skarlett's Avatar
    Join Date
    Apr 2013
    Posts
    405
    Thanks given
    47
    Thanks received
    7
    Rep Power
    13
    Quote Originally Posted by Demolition View Post
    Works fine on mine >.> maybe because you might have to implement something else in a different file for it to have a title ? I have 2 spaces in my username and it works. Try re writing the command different format
    Is your command the same as mine?
    I can give players with one word names a title, just not two letters. .-.
    ♡Lovvveeee♡
    Reply With Quote  
     

  4. #4  
    Registered Member Skarlett's Avatar
    Join Date
    Apr 2013
    Posts
    405
    Thanks given
    47
    Thanks received
    7
    Rep Power
    13
    BUMP I also need it for 3 letter names >.>
    ♡Lovvveeee♡
    Reply With Quote  
     

  5. #5  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    When typing the username, use underscores '_' instead of spaces ' '.
    Then when processing the username, which should be args[2] (with underscores), replace the underscores with spaces:
    Code:
    String playerToGiveTitle = args[2].replace('_', ' ');
    Reply With Quote  
     

  6. #6  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Quote Originally Posted by TheChosenOne View Post
    When typing the username, use underscores '_' instead of spaces ' '.
    Then when processing the username, which should be args[2] (with underscores), replace the underscores with spaces:
    Code:
    String playerToGiveTitle = args[2].replace('_', ' ');

    Just use substring for the title then use your ([args]) for the actual name?

    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  
     

  7. #7  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    Quote Originally Posted by Ninth Legion View Post
    Just use substring for the title then use your ([args]) for the actual name?
    That's only possible when the command (besides the playername) has a fixed length, so no numerical arguments for example.
    Reply With Quote  
     

  8. #8  
    Spread Love

    Dhruv's Avatar
    Join Date
    Feb 2012
    Age
    28
    Posts
    1,011
    Thanks given
    157
    Thanks received
    167
    Rep Power
    215
    Try changing this:

    Code:
    if (args.length == 3) {
    Change the "3" too the max amount of characters you can put in a name. But put an extra number after..

    For example:

    Code:
    if (args.length == 3) {
    Too:

    Code:
    if (args.length == 9) {
    if you choose 8 put 9.

    Total guess so try it.
    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. [Pi] Commands do not register 2-Word Names
    By Skarlett in forum Help
    Replies: 10
    Last Post: 06-08-2013, 01:10 PM
  2. Replies: 4
    Last Post: 05-19-2013, 10:33 AM
  3. [PI] Highscores do not connect?
    By Name Me Noob in forum Help
    Replies: 7
    Last Post: 04-07-2013, 01:21 PM
  4. [PI] I do not know how.
    By EvoIllusions in forum Help
    Replies: 10
    Last Post: 10-13-2012, 08:08 PM
  5. [PI] PM log not adding 2nd players name.
    By killdogz in forum Help
    Replies: 0
    Last Post: 07-11-2011, 04:41 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •