Thread: whats wrong with this? [508]

Results 1 to 6 of 6
  1. #1 whats wrong with this? [508] 
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    this in itemselect.java:

    Code:
    case ####:
    			for(Player pl : Engine.players) {
    			if (pl != null) {
                    Engine.newSummonNPC2(####, p.absX, p.absY, p.heightLevel);
    		pl.createGlobalObject(####, p.heightLevel, p.absX, p.absY, -1, 10);
                		pi.deleteItem(p, itemId, itemSlot, 1);
    }
    }
    break;
    it works great: summons the npc and object for all players, but why this doesnt work:

    in NPC.java:

    Code:
    			if (npcType == ####)
    			{
    			for(Player pl : Engine.players) {
    			if (pl != null) {
    		pl.createGlobalObject(6951, p.heightLevel, absX, absY, 0, 10);
    				return;
    			}
    			}
    			}

    this removes the object only from the killer, how to make it remove it from all players???
    ...
    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
    Quote Originally Posted by mige5 View Post
    Code:
    			if (npcType == ####)
    			{
    			for(Player pl : Engine.players) {
    			if (pl != null) {
    		pl.createGlobalObject(6951, p.heightLevel, absX, absY, 0, 10);
    				return;
    			}
    			}
    			}
    Should
    Code:
    pl.createGlobalObject(6951, p.heightLevel, absX, absY, 0, 10);
    be (I'm guessing)
    Code:
    pl.createGlobalObject(6951, p.heightLevel, p.absX, p.absY, 0, 10);
    That should fix it, if you are trying to remove the object you created, but only if the players haven't moved.

    I'm not exactly sure what you are trying to do, but if you want to remove all the objects you created, you would have to make some sort of list like an array or arraylist.

    Also, if a player logs in after the object is created, they won't be able to see it, same with the NPC created.

    PM me if that is what you want to do and you aren't sure how, I think I have a pretty good idea.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. #3  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    no i dont want to add it like this: p.absX and p.absY, because they mean player coordinates, and the current im using means NPC coordinates so it is good...
    ...
    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
    It isn't good, because it doesn't work. It was hard to understand what you were trying to do, you gave me 2 blocks of code and said fix it.
    Your code does not remove the object from the killer, it removes it from the first valid player in the player list. I'll explain why.
    Code:
    if (npcType == ####)
    			{
    			for(Player pl : Engine.players) {
    			if (pl != null) {
    		pl.createGlobalObject(6951, p.heightLevel, absX, absY, 0, 10);
    				return;
    			}
    			}
    			}
    "return" instructs the JVM to exit the current method and move on to the next one.
    Anything under "return" is never reached.

    If you deleted

    Code:
    return;
    the loop should run through everyone as well as continue past the loop.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Oct 2008
    Posts
    314
    Thanks given
    0
    Thanks received
    39
    Rep Power
    33
    replace return to continue..... I thought the tut on multi spells would teach people.
    Reply With Quote  
     

  6. #6  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    Quote Originally Posted by Illuminate View Post
    It isn't good, because it doesn't work. It was hard to understand what you were trying to do, you gave me 2 blocks of code and said fix it.
    Your code does not remove the object from the killer, it removes it from the first valid player in the player list. I'll explain why.
    Code:
    if (npcType == ####)
    			{
    			for(Player pl : Engine.players) {
    			if (pl != null) {
    		pl.createGlobalObject(6951, p.heightLevel, absX, absY, 0, 10);
    				return;
    			}
    			}
    			}
    "return" instructs the JVM to exit the current method and move on to the next one.
    Anything under "return" is never reached.

    If you deleted

    Code:
    return;
    the loop should run through everyone as well as continue past the loop.
    THX! deleted the return and worked!
    ...
    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
  •