Post this code
line 9618 of client.java (5 lines above and below)
line 850 of client.java (5 lines above and below)
|
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
Post this code
line 9618 of client.java (5 lines above and below)
line 850 of client.java (5 lines above and below)
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();
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
toCode:if (IsAttackingNPC && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) { 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..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();
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();
}
}
Change
toCode:if (IsAttacking && !IsDead && System.currentTimeMillis() - PkingDelay >= Fighting) { if (PlayerManager.players[AttackingOn] != null) { if (!PlayerManager.players[AttackingOn].IsDead) { Attack(); } else { ResetAttack(); } } else { ResetAttack(); } }
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(); } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |