Thread: [PI] Can't use underscore or spaced names Fix

Results 1 to 5 of 5
  1. #1 [PI] Can't use underscore or spaced names Fix 
    Registered Member
    Join Date
    Aug 2009
    Posts
    608
    Thanks given
    1
    Thanks received
    17
    Rep Power
    6
    If you have a command that you can't use on a specific person because they have an underscore or a space in there name, look no farther.

    Find something similiar to:
    Code:
            String[] args = playerCommand.split(" ");
            String playerToGive = args[1];
            int itemToGive = Integer.parseInt(args[2]);
            int amountToGive = Integer.parseInt(args[3]);
    Basically the above code is used as, (for example): ::giveitem kerry 1394 1
    Now, the playerCommand.split(" "); means, after the command ::giveitem is called, it will look for argument one, which in this case is the playerToGive.
    Then it will look for argument 2 which is itemToGive, then argument 3 which is amountToGive.
    Now let's say you want to give it to a player name: Ice Cream.
    In this case, Ice is being ready as argument 1 and Cream is being read as argument 2 which is really the itemToGive.

    Simple fix.

    If your command is like ::giveitem which giveitem is 8 chars, you would want to change the () inside substring to make it 9. Why? Because the 9th character is a space and anything beyond that will be read as playerToGive.

    Replace it with:
    String playerToGive = playerCommand.substring(9);
    Now afterwords, add:
    String[] args = playerCommand.split(" ");
    int itemToGive = Integer.parseInt(args[1]);
    int amountToGive = Integer.parseInt(args[2]);
    This mite work, I'm not sure. I will test tomorrow.
    The above code is used as:
    ::giveitem playername (TWO SPACES BETWEEN PLAYERNAME AND THIS)ItemID Amount
    so example:
    ::giveitem Kennedy Burns 4587 1
    Two spaces between burns and the item id (4587).
    Reply With Quote  
     

  2. #2  
    I'm Baack...


    Join Date
    Mar 2011
    Posts
    1,663
    Thanks given
    281
    Thanks received
    202
    Rep Power
    324
    Thats interesting...... Thanks for this lil tut, I'll probably use to modify a few of my commands
    I'm back
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Aug 2009
    Posts
    608
    Thanks given
    1
    Thanks received
    17
    Rep Power
    6
    Quote Originally Posted by 'Sillhouette View Post
    Thats interesting...... Thanks for this lil tut, I'll probably use to modify a few of my commands
    Haven't really tested it but a lot of people have had problems with spaces and underscores.
    Reply With Quote  
     

  4. #4  
    I'm Baack...


    Join Date
    Mar 2011
    Posts
    1,663
    Thanks given
    281
    Thanks received
    202
    Rep Power
    324
    Yeah that includes me and I haven't tested yet :\ no time haha
    I'm back
    Reply With Quote  
     

  5. #5  
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    464
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Nice, I asked for this a while back in help, bookmarked and repped++ will test tomrrow.
    ~Treq~ (Previously Spetsnaz)
    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. Changing NPC names item names & object names!
    By medabi3 in forum Tutorials
    Replies: 8
    Last Post: 05-24-2013, 07:36 PM
  2. [462] Npc ids/names. Object ids/names/options
    By Brown in forum Configuration
    Replies: 0
    Last Post: 08-23-2009, 10:25 PM
  3. Cleaned v4 spaced
    By Ziya in forum Requests
    Replies: 1
    Last Post: 01-11-2009, 11:44 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
  •