Thread: Npc Transform

Results 1 to 6 of 6
  1. #1 Npc Transform 
    Donator
    South-Park's Avatar
    Join Date
    Jul 2012
    Posts
    806
    Thanks given
    191
    Thanks received
    111
    Rep Power
    43
    Ok so I'm adding sheep shearing and this is my code

    Code:
    public static void shearSheep(Client c, int npcId) {
    		switch (npcId) {
    		case 43:
    			c.startAnimation(893);
    			for (int i = 1; i < NPCHandler.maxNPCs; i++) {
    				if (NPCHandler.npcs[i] == null) {
    					NPCHandler.npcs[i].requestTransform(42);
    					return;
    				}
    			} 
    			return;
    		}
    	}
    But when eve I shear a sheep it changes all of the npcs to npc 42. How would I make it where it only changes that one npc?


    The community these days makes my lol.

    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    May 2012
    Age
    28
    Posts
    1,548
    Thanks given
    415
    Thanks received
    231
    Rep Power
    81
    You're looping through all the sheeps, that's why.
    Inactive.


    Spoiler for FirstDesign:
    Reply With Quote  
     

  3. #3  
    Donator
    South-Park's Avatar
    Join Date
    Jul 2012
    Posts
    806
    Thanks given
    191
    Thanks received
    111
    Rep Power
    43
    I tryed this, still didn't work.

    Code:
    case 43:
    			c.startAnimation(893);
    			  NPCHandler.npcs[npcId].requestTransform(42);
    			return;


    The community these days makes my lol.

    Reply With Quote  
     

  4. #4  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    Unless requestTransform(int) is a static method, that should throw a NullpointerException (it performs a method on the first null npc it encounters instead).
    Either your problem is related to a static requestTransform(int) method or it has nothing to do with the shown method at all.

    I also don't see anything that identifies that one particular npc (I except not only the npcId but also an index in the npcArray, which should be information received from the ObjectOnNpc packet).

    EDIT: is npcId the place in the index or is it the npcType's id?
    Reply With Quote  
     

  5. #5  
    Donator
    South-Park's Avatar
    Join Date
    Jul 2012
    Posts
    806
    Thanks given
    191
    Thanks received
    111
    Rep Power
    43
    Quote Originally Posted by TheChosenOne View Post
    Unless requestTransform(int) is a static method, that should throw a NullpointerException (it performs a method on the first null npc it encounters instead).
    Either your problem is related to a static requestTransform(int) method or it has nothing to do with the shown method at all.

    I also don't see anything that identifies that one particular npc (I except not only the npcId but also an index in the npcArray, which should be information received from the ObjectOnNpc packet).

    EDIT: is npcId the place in the index or is it the npcType's id?
    Just the id of npc. And it does throw a NullpointerException.


    The community these days makes my lol.

    Reply With Quote  
     

  6. #6  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    The changing of all the npcs isn't due to the method posted above then.
    You're looking to do something like:
    Code:
    if(npc[npcIndex].npcId == 43){
        c.startAnimation(893);
        npc[npcIndex].requestTransform(42);
    }
    Other checks could be possible (to see if the sheep has been shorn already: check the current transform value).
    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

Similar Threads

  1. Npc transforming method?
    By Soulzz in forum Help
    Replies: 1
    Last Post: 08-01-2009, 03:56 PM
  2. [508 RS2HD] Npc transformation
    By Pro Gram Mer in forum Tutorials
    Replies: 18
    Last Post: 06-02-2009, 10:06 AM
  3. Npc transforms you \_,,..Delta..,,_/
    By *~Pwnt~* in forum Snippets
    Replies: 11
    Last Post: 04-17-2009, 08:17 PM
  4. Npc transforming! Best ever! [vid]
    By mige5 in forum Projects
    Replies: 17
    Last Post: 12-29-2008, 01:15 AM
  5. Npc transforms you into an npc
    By *~Pwnt~* in forum Tutorials
    Replies: 7
    Last Post: 12-28-2008, 02:24 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •