Thread: hepl plz!

Results 1 to 6 of 6
  1. #1 hepl plz! 
    Registered Member
    Join Date
    Jul 2008
    Posts
    291
    Thanks given
    0
    Thanks received
    0
    Rep Power
    27
    i got this after the server is 5 min online
    exception in thread "main" java.lang.arrayindexoutofboundsexception: -1
    at client.attacknpc(client.java:9618)
    at client.process(client.java:850)
    at playermanager.process(playermanager.java:118)
    at server.main (server.java:40)

    then everyone logs out and if they want to login they are already logged in
    Reply With Quote  
     

  2. #2  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    Post this code
    line 9618 of client.java (5 lines above and below)
    line 850 of client.java (5 lines above and below)
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jul 2008
    Posts
    291
    Thanks given
    0
    Thanks received
    0
    Rep Power
    27
    line 9618 5 above and below

    Server.NpcManager.npcs[attacknpc].hitUpdateRequired = true;
    addSkillXP(140 * hitDiff, 4);
    addSkillXP(80 * hitDiff, 3);
    }
    }
    if (Server.NpcManager.npcs[attacknpc].npcType != 2745) {
    Server.NpcManager.npcs[attacknpc].StartKilling = playerId;
    Server.NpcManager.npcs[attacknpc].RandomWalk = false;
    Server.NpcManager.npcs[attacknpc].followingPlayer = true;
    Server.NpcManager.npcs[attacknpc].followPlayer = playerId;
    Server.NpcManager.npcs[attacknpc].IsUnderAttack = true;

    line 850 5 above and below


    }
    }
    if (IsAttackingNPC && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if (Server.NpcManager.npcs[attacknpc] != null) {
    if (!Server.NpcManager.npcs[attacknpc].IsDead) {
    AttackNPC();
    } else {
    ResetAttackNPC();
    }
    } else {
    ResetAttackNPC();
    Reply With Quote  
     

  4. #4  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    Wait..

    Sorry, I need to see more than that
    Post the whole method (attackNPC()) for me (in client.java)?

    Oh, by the way. This Exception is being thrown because the player is no longer attacking the npc, but the code still thinks that -1 is a valid ID. However, the first index of an array is 0, thus making -1 out of range.

    OR

    you could change
    Code:
    if (IsAttackingNPC && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if (Server.NpcManager.npcs[attacknpc] != null) {
    if (!Server.NpcManager.npcs[attacknpc].IsDead) {
    AttackNPC();
    } else {
    ResetAttackNPC();
    }
    } else {
    ResetAttackNPC();
    to
    Code:
    if (IsAttackingNPC && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if(attacknpc < 0)
    {
    ResetAttackNPC();
    return;
    }
    if (Server.NpcManager.npcs[attacknpc] != null) {
    if (!Server.NpcManager.npcs[attacknpc].IsDead) {
    AttackNPC();
    } else {
    ResetAttackNPC();
    }
    } else {
    ResetAttackNPC();
    But just a heads up, this way of doing it leaves much potential for the Exception to occur again..
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jul 2008
    Posts
    291
    Thanks given
    0
    Thanks received
    0
    Rep Power
    27
    i still got the problem



    if (IsAttacking && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if (PlayerManager.players[AttackingOn] != null) {
    if (!PlayerManager.players[AttackingOn].IsDead) {
    Attack();
    } else {
    ResetAttack();
    }
    } else {
    ResetAttack();
    }
    }
    if (IsAttackingNPC && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if(attacknpc < 0)
    {
    ResetAttackNPC();
    return;
    }
    if (Server.NpcManager.npcs[attacknpc] != null) {
    if (!Server.NpcManager.npcs[attacknpc].IsDead) {
    AttackNPC();
    } else {
    ResetAttackNPC();
    }
    } else {
    ResetAttackNPC();
    }
    }
    Reply With Quote  
     

  6. #6  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    Change
    Code:
    if (IsAttacking && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if (PlayerManager.players[AttackingOn] != null) {
    if (!PlayerManager.players[AttackingOn].IsDead) {
    Attack();
    } else {
    ResetAttack();
    }
    } else {
    ResetAttack();
    }
    }
    to

    Code:
    if (IsAttacking && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) {
    if(AttackingOn == -1)
    {
    ResetAttack();
    return false;
    }
    if (PlayerManager.players[AttackingOn] != null) {
    if (!PlayerManager.players[AttackingOn].IsDead) {
    Attack();
    } else {
    ResetAttack();
    }
    } else {
    ResetAttack();
    }
    }
    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
  •