Thread: NullPointerException Help...

Results 1 to 9 of 9
  1. #1 NullPointerException Help... 
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    I'm adding barrows and I get this Null Pointer..
    Code:
    Starting Impact Pk on 0.0.0.0:43594
    ClientHandler: Accepted from localhost:4769
    Core has connected
    Core - actionbutton: 21247
    Core - actionbutton: 24133
    playerCommand: tele 3564 3288
    playerCommand: pickup 952 1
    objectType: 6821
    Exception in thread "main" java.lang.NullPointerException
            at server.npcs.NPCHandler.process(NPCHandler.java:445)
            at server.Server.main(Server.java:27)
    ClientHandler: Accepted from localhost:4779
    Core has connected
    Read it and went to NPCHandler line 445 and here it is...
    Code:
    Client o = (Client) Server.playerHandler.players[c.killerId];
    						if(o != null) {
    							if (npcs[i].npcType == 2025 || npcs[i].npcType == 2026 || npcs[i].npcType == 2027 || npcs[i].npcType == 2028 || npcs[i].npcType == 2029 || npcs[i].npcType == 2030) {
    								o.BarrowskillCount++;
    							}
    							if (npcs[i].npcType == 2025) {
    								o.Ahrim = true;
    								o.sendMessage("You have defeated Ahrim!");
    							}
    							if (npcs[i].npcType == 2026) {
    								o.Dharok = true;
    								o.sendMessage("You have defeated Dharok!");
    							}
    							if (npcs[i].npcType == 2027) {
    								o.Guthan = true;
    								o.sendMessage("You have defeated Guthan!");
    							}
    							if (npcs[i].npcType == 2028) {
    								o.Karil = true;
    								o.sendMessage("You have defeated Karil!");
    							}
    							if (npcs[i].npcType == 2029) {
    								o.Torag = true;
    								o.sendMessage("You have defeated Torag!");
    							}
    							if (npcs[i].npcType == 2030) {
    								o.Verac = true;
    								o.sendMessage("You have defeated Verac!");
    							}
    						}
    Not seeing really anything wrong with it...
    Any help anyone?
    Reply With Quote  
     

  2. #2  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    30
    Posts
    2,660
    Thanks given
    53
    Thanks received
    331
    Rep Power
    925
    Code:
    Client o = (Client) Server.playerHandler.players[c.killerId];
    If killerId is null (hence the NullPointerException), it'll throw back that error.


    `Ex-global moderator x3 (resigned)
    Reply With Quote  
     

  3. #3  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    So how would I make it not give a null?
    Reply With Quote  
     

  4. #4  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    30
    Posts
    2,660
    Thanks given
    53
    Thanks received
    331
    Rep Power
    925
    You just need to make it check to see if the player is null, and if it isn't, make it continue.


    `Ex-global moderator x3 (resigned)
    Reply With Quote  
     

  5. #5  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Already in there...
    Code:
    if(o != null) {
    Reply With Quote  
     

  6. #6  
    crypt or blood
    Guest
    Looks like the c. in "c.killerId" is null.

    So,
    Code:
    if(c != null) Client o = (Client) Server.playerHandler.players[c.killerId];
    Reply With Quote  
     

  7. #7  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Hmm I'll check out another source.

    ---------- Post added at 04:40 PM ---------- Previous post was at 04:33 PM ----------

    w00t think it works
    Reply With Quote  
     

  8. #8  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    It's okay I'm here now.

    It is the NPC class causing the problem.

    Try this:
    Code:
    if(o != null && npcs[i] != null) {
    Reply With Quote  
     

  9. #9  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    I fixed this hours ago...
    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
  •