Thread: Error

Results 1 to 8 of 8
  1. #1 Error 
    Registered Member
    Join Date
    Aug 2012
    Posts
    349
    Thanks given
    5
    Thanks received
    2
    Rep Power
    0
    I've got a getip command which is
    [SPOIL]
    Code:
    			if (cmd[0].equalsIgnoreCase("getip")) {
    				String name = "";
    				for (int i = 1; i < cmd.length; i++)
    					name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
    				Player p = World.getPlayerByDisplayName(name);
    				if (p == null) {
    					player.getPackets().sendGameMessage(
    							"Couldn't find player " + name + ".");
    				} else
    					player.getPackets().sendGameMessage(
    							"" + p.getDisplayName() + "'s IP is "
    									+ p.getSession().getIP() + ".");
    				return true;
    			}
    [/SPOIL]
    However i get this error when compiling
    [SPOIL][/SPOIL]
    Code:
    starting...
    src\com\rs\game\player\content\commands\Administrator.java:409: error: variable
    name is already defined in method processCommand(Player,String[],boolean,boolean
    )
                                    String name = "";
                                           ^
    Note: src\com\rs\content\exchange\GrandExchange.java uses unchecked or unsafe op
    erations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    Press any key to continue . . .
    Could someone please fix my getip command
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Aug 2012
    Posts
    349
    Thanks given
    5
    Thanks received
    2
    Rep Power
    0
    Someone please help me
    Reply With Quote  
     

  3. #3  
    The stupid noob


    Join Date
    May 2011
    Age
    26
    Posts
    2,227
    Thanks given
    2,446
    Thanks received
    1,100
    Rep Power
    852
    "String name = "";"
    Has already been defined as a String, remove the String so it's "name = "";"
    Working on a 592 project c:
    Reply With Quote  
     

  4. #4  
    Success is the worst teacher

    Santa Hat's Avatar
    Join Date
    Oct 2012
    Age
    24
    Posts
    3,337
    Thanks given
    801
    Thanks received
    1,185
    Rep Power
    189
    remove the String name so here:

    if (cmd[0].equalsIgnoreCase("getip")) {
    for (int i = 1; i < cmd.length; i++)
    name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
    Player p = World.getPlayerByDisplayName(name);
    if (p == null) {
    player.getPackets().sendGameMessage(
    "Couldn't find player " + name + ".");
    } else
    player.getPackets().sendGameMessage(
    "" + p.getDisplayName() + "'s IP is "
    + p.getSession().getIP() + ".");
    return true;
    }

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Aug 2012
    Posts
    349
    Thanks given
    5
    Thanks received
    2
    Rep Power
    0
    Another error
    [SPOIL]
    Code:
    starting...
    src\com\rs\game\player\content\commands\Administrator.java:410: error: variable
    name might not have been initialized
                        name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
                        ^
    src\com\rs\game\player\content\commands\Administrator.java:411: error: variable
    name might not have been initialized
                        Player p = World.getPlayerByDisplayName(name);
                                                                ^
    Note: src\com\rs\content\exchange\GrandExchange.java uses unchecked or unsafe op
    erations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    Press any key to continue . . .
    [/SPOIL]
    Reply With Quote  
     

  6. #6  
    Lee
    Lee is offline
    Registered Member

    Join Date
    Feb 2012
    Age
    27
    Posts
    786
    Thanks given
    135
    Thanks received
    90
    Rep Power
    171
    Quote Originally Posted by dragonmage View Post
    Another error
    [SPOIL]
    Code:
    starting...
    src\com\rs\game\player\content\commands\Administrator.java:410: error: variable
    name might not have been initialized
                        name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
                        ^
    src\com\rs\game\player\content\commands\Administrator.java:411: error: variable
    name might not have been initialized
                        Player p = World.getPlayerByDisplayName(name);
                                                                ^
    Note: src\com\rs\content\exchange\GrandExchange.java uses unchecked or unsafe op
    erations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    Press any key to continue . . .
    [/SPOIL]
    No such variable.


    name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
    Starting a new account on RS07 hoping for someone to play alongside with, PM me.
    Reply With Quote  
     

  7. #7  
    The stupid noob


    Join Date
    May 2011
    Age
    26
    Posts
    2,227
    Thanks given
    2,446
    Thanks received
    1,100
    Rep Power
    852
    Quote Originally Posted by dragonmage View Post
    Another error
    [SPOIL]
    Code:
    starting...
    src\com\rs\game\player\content\commands\Administrator.java:410: error: variable
    name might not have been initialized
                        name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
                        ^
    src\com\rs\game\player\content\commands\Administrator.java:411: error: variable
    name might not have been initialized
                        Player p = World.getPlayerByDisplayName(name);
                                                                ^
    Note: src\com\rs\content\exchange\GrandExchange.java uses unchecked or unsafe op
    erations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    Press any key to continue . . .
    [/SPOIL]
    Please watch this video, I think it will help you a bunch with errors; [Only registered and activated users can see links. ]
    Working on a 592 project c:
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Aug 2012
    Posts
    349
    Thanks given
    5
    Thanks received
    2
    Rep Power
    0
    Could someone send me the code off their commands please?
    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. Same error over and over?!!
    By phantomphreak in forum Tutorials
    Replies: 4
    Last Post: 09-28-2007, 01:20 AM
  2. Basic Compile Errors
    By Daniel in forum Tutorials
    Replies: 4
    Last Post: 09-17-2007, 12:54 PM
  3. [HELP]Render Error
    By Big J in forum General
    Replies: 3
    Last Post: 07-30-2007, 01:01 AM
  4. Error. Please reboot me :)
    By Inside Sin in forum Showcase
    Replies: 4
    Last Post: 05-13-2007, 03:39 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
  •