Thread: Please help me with this.... ='[

Results 1 to 3 of 3
  1. #1 Please help me with this.... ='[ 
    Registered Member
    ¤~W.I.L.L~¤'s Avatar
    Join Date
    Jun 2008
    Age
    29
    Posts
    390
    Thanks given
    3
    Thanks received
    12
    Rep Power
    300
    Ok so, I'm trying to add a few names to some of my commands, and some very annoying things keep happening.
    First, here's what i'm doing to add the names (just incase i'm doing it wrong...)
    Code:
    if (command.startsWith("demote") && playerName.equalsIgnoreCase("name1") || playerName.equalsIgnoreCase("name2")) {
    String name = command.substring(7);
    try {
    int p = PlayerHandler.getPlayerID(name);
    client c = (client) server.playerHandler.players[p];
    c.playerRights = 0;
    yell(name+" is no longer a member of staff");
    } catch(Exception e) {
    sM(name+" either isn't online or doesn't exist");
    }
    }
    When I try to use the yell command, it sends this message
    Code:
    name+" either isn't online or doesn't exist");
    Except instead of a name, it sends the last few letters of whatever I try to yell. Now, if I continue to add the extra names to other commands, I Disconnect when I try to use any command, and it prints this in my server cmd
    Code:
    [Name1]: Logged in
    Exception encountered while parsing incoming packets from Name1.
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            at java.lang.String.substring(Unknown Source)
            at java.lang.String.substring(Unknown Source)
            at client.customCommand(client.java:8458)
            at client.parseIncomingPackets(client.java:15590)
            at client.packetProcess(client.java:17315)
            at PlayerHandler.process(PlayerHandler.java:271)
            at process.run(process.java:23)
            at java.lang.Thread.run(Unknown Source)
    [Name1]: Disconnected
    I would really appreciate if someone would help me out with this. Thanks,

    ~will
    | Official Forum Rules | ShoutBox Rules |
    ^ Learn them. Live them. Love them. ^

    Quote Originally Posted by Jerkin View Post
    Sorry for Gravedigging, but I was wondering what do i do if i'm using delta and don't have a filemanager, thanks.
    Quote Originally Posted by Sydney View Post
    Everything wrong started with your first three words. Also, if you're using Delta, I advise you get out of the 508+ sections.
    /facepalm
    Reply With Quote  
     

  2. #2  
    Member

    Join Date
    Sep 2007
    Posts
    614
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Code:
    if (command.startsWith("demote") && playerName.equalsIgnoreCase("name1") || playerName.equalsIgnoreCase("name2")) {
    Basically this says if command is demote and playername is whatever OR playername is whatever.

    So basically, having the player name to whatever is enough to trigger this entire command.

    Code:
    if (command.startsWith("demote") && (playerName.equalsIgnoreCase("name1") || playerName.equalsIgnoreCase("name2"))) {
    Notice the extra ( ) after the &&. This means it checks the conditions inside the new ( ) first, so it can check either player name, but it must be one of them.

    That is causing the next error.
    Reply With Quote  
     

  3. #3  
    Registered Member
    ¤~W.I.L.L~¤'s Avatar
    Join Date
    Jun 2008
    Age
    29
    Posts
    390
    Thanks given
    3
    Thanks received
    12
    Rep Power
    300
    FFS, thank you, lol. I can't believe I didn't notice that I was missing those parentheses. Thanks again for the help.
    | Official Forum Rules | ShoutBox Rules |
    ^ Learn them. Live them. Love them. ^

    Quote Originally Posted by Jerkin View Post
    Sorry for Gravedigging, but I was wondering what do i do if i'm using delta and don't have a filemanager, thanks.
    Quote Originally Posted by Sydney View Post
    Everything wrong started with your first three words. Also, if you're using Delta, I advise you get out of the 508+ sections.
    /facepalm
    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
  •