Thread: [PI] Npc's teleport you with multiple options

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 [PI] Npc's teleport you with multiple options 
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    463
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Purpose: For people who can't figure this out
    Difficulty: 5/10
    Assumed Knowledge: How to access basic server files
    Classes Modified: DialogueHandler, ClickingButtons, ActionHandler, Spawn-Config.cfg
    Tested On(if it applies): Project Insanity

    ***Please note: If you are going to flame this because you already know how to do it, there is no need at all, I could really care less. It is here for people to learn and improve their skills.***

    Alright Making a quick tutorial on how to make a Npc dialogue like this:



    Step 1. Open up Spawn-Config.cfg and add in this:

    Code:
    spawn = 599	3193	3425	0	0	0	0	0	Wizard
    I am making a wizard do the teleport options.

    I'm assuming you know how to change the Npc Id and other configurational settings in it already so lets move on.

    Step 2:

    Open up ActionHandler.java and insert this:

    Code:
    			case 599: 
    				c.getDH().sendDialogues(100, npcType); 
    			break;
    Please note that the... (100, npcType); ...is the Dialogue you want to pull up.

    The case 599: is the npc id that we want to initiate the dialogue sequence.

    We are pulling up Dialogue 100.

    Step 3:

    Open up DialogueHandler.java and insert this under your last "case":

    Code:
    		case 100:
    			sendOption5("Tormented Demons", "Corporeal Beast", "Godwars", "Chaos Elemental", "Dagganoths");
    			c.teleAction = 45;
    		break;
    Case 100 is the dialogue we want to pull up.
    SendOption5 is the choices we would like to give our users.
    c.teleAction = 45 is the id so the computer knows were doing those options and not some other option like runecrafting teleports etc...

    Step 4:

    Now that all of that is added on to the part the most people mess up on and do not understand.

    Open up ClickingButtons.java and press ctrl + F to navigate to this line of code:

    Code:
    case 9190:
    Right under that there should be an if-statement that teleports you somewhere.

    You have two options now with this piece of code we are going to insert.

    Code:
    				 if (c.teleAction == 45) {
    					//tormented demons
    					c.getPA().spellTeleport(2717, 9802, 0);
                                                                    c.sendMessage("You teleport to the Tormented Demons chamber!");
    First option: if you want to throw it right under the case 9190: you will be using the above code:

    Second option: if you want to put it further into the case you will have to use the else- if statement as shown below.

    Code:
    	} else if (c.teleAction == 45) {
    					//tormented demons
    					c.getPA().spellTeleport(2717, 9802, 0);
                                                                    c.sendMessage("You teleport to the Tormented Demons chamber!");
    Always make sure to close with a "}" or your code will not run.

    Now your probably wondering how do I know the correct case for putting the code in?

    Let me explain...



    When you click an option your server command prompt window should tell you the action button id (if you have server debugging turned ON)

    So clicking that we know that our 5 lines are going to be:



    You can now finish adding your if - statements to the cases going in order from 9190 and down for every chat line.

    And you have learned that the c.teleAction is used to identify which teleport you want to call.

    You may want to make your c.teleAction = -1 at the end of your if statements but it is completely up to you.

    I hope you have learned alot from my tutorial. Thanks for reading!


    Post any Errors/Questions.
    ~Treq~ (Previously Spetsnaz)
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Banned

    Join Date
    Apr 2009
    Posts
    988
    Thanks given
    12
    Thanks received
    22
    Rep Power
    0
    howd you get the action buttons i need a command that will do the same thing urs did?
    Reply With Quote  
     

  4. #3  
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    463
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Quote Originally Posted by Flippy View Post
    howd you get the action buttons i need a command that will do the same thing urs did?
    Just click it, it will pop up in the black command prompt window. If your doing teleports like this you can just use the cases shown in the tutorial, It should work.
    ~Treq~ (Previously Spetsnaz)
    Reply With Quote  
     

  5. #4  
    Banned

    Join Date
    Apr 2009
    Posts
    988
    Thanks given
    12
    Thanks received
    22
    Rep Power
    0
    theres somethiing that makes that happen cause it doesnt work for me
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    463
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Quote Originally Posted by Flippy View Post
    theres somethiing that makes that happen cause it doesnt work for me
    You should have print it to the console. Let me show you how...

    Go into ClickingButtons.java at the top of the class.

    This is the code you use:

    If the players rights are greater than or equal to three, print the action button to the console

    Code:
    		if(c.playerRights >= 3)	
    			Misc.println(c.playerName+ " - actionbutton: "+actionButtonId);
    Here is what mine looks like (just the start of my file):

    Make yours look like mine... Post any errors and i'll be glad to help.


    Code:
    package server.model.players.packets;
    
    import server.Config;
    import server.Server;
    import server.model.items.GameItem;
    import server.model.players.Client;
    import server.model.players.SkillMenu;
    import server.model.players.PacketType;
    import server.model.players.SkillGuides;
    import server.util.Misc;
    import server.event.EventContainer;
    import server.event.Event;
    import server.event.EventManager;
    
    /**
     * Clicking most buttons
     **/
    public class ClickingButtons implements PacketType {
    
    	@Override
    	public void processPacket(Client c, int packetType, int packetSize) {
    		int actionButtonId = Misc.hexToInt(c.getInStream().buffer, 0, packetSize);
    		//int actionButtonId = c.getInStream().readShort();
    		if (c.isDead)
    			return;
    		if(c.playerRights >= 3)	
    			Misc.println(c.playerName+ " - actionbutton: "+actionButtonId);
    			
    		switch (actionButtonId){
    //begin random event
    			case 63013:
    			if(c.pieSelect == 1) {
    			c.getPA().closeAllWindows();
    			c.getItems().addItem(995,100000);
    			c.sendMessage("Congratulations, you have completed the random event!");
    			}
    Hope I helped.
    ~Treq~ (Previously Spetsnaz)
    Reply With Quote  
     

  8. #6  
    Registered Member saran's Avatar
    Join Date
    Oct 2010
    Posts
    260
    Thanks given
    32
    Thanks received
    6
    Rep Power
    3
    nice and this rlly helped me cus im new to coding servers but i guess u helped me some way rep'd.


    Reply With Quote  
     

  9. #7  
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    463
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Quote Originally Posted by saran View Post
    nice and this rlly helped me cus im new to coding servers but i guess u helped me some way rep'd.
    Thank-you if you have any questions about coding or ideas for a tutorial message me.
    ~Treq~ (Previously Spetsnaz)
    Reply With Quote  
     

  10. #8  
    Registered Member
    Join Date
    May 2011
    Posts
    82
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    How do I make a "More" option that goes to another dialogue? Like the Runecrafting teleport one.
    Reply With Quote  
     

  11. #9  
    Registered Member
    Join Date
    Sep 2010
    Posts
    627
    Thanks given
    170
    Thanks received
    53
    Rep Power
    29
    [SPOIL]
    Quote Originally Posted by toxic melee View Post
    Purpose: For people who can't figure this out
    Difficulty: 5/10
    Assumed Knowledge: How to access basic server files
    Classes Modified: DialogueHandler, ClickingButtons, ActionHandler, Spawn-Config.cfg
    Tested On(if it applies): Project Insanity

    ***Please note: If you are going to flame this because you already know how to do it, there is no need at all, I could really care less. It is here for people to learn and improve their skills.***

    Alright Making a quick tutorial on how to make a Npc dialogue like this:



    Step 1. Open up Spawn-Config.cfg and add in this:

    Code:
    spawn = 599	3193	3425	0	0	0	0	0	Wizard
    I am making a wizard do the teleport options.

    I'm assuming you know how to change the Npc Id and other configurational settings in it already so lets move on.

    Step 2:

    Open up ActionHandler.java and insert this:

    Code:
    			case 599: 
    				c.getDH().sendDialogues(100, npcType); 
    			break;
    Please note that the... (100, npcType); ...is the Dialogue you want to pull up.

    The case 599: is the npc id that we want to initiate the dialogue sequence.

    We are pulling up Dialogue 100.

    Step 3:

    Open up DialogueHandler.java and insert this under your last "case":

    Code:
    		case 100:
    			sendOption5("Tormented Demons", "Corporeal Beast", "Godwars", "Chaos Elemental", "Dagganoths");
    			c.teleAction = 45;
    		break;
    Case 100 is the dialogue we want to pull up.
    SendOption5 is the choices we would like to give our users.
    c.teleAction = 45 is the id so the computer knows were doing those options and not some other option like runecrafting teleports etc...

    Step 4:

    Now that all of that is added on to the part the most people mess up on and do not understand.

    Open up ClickingButtons.java and press ctrl + F to navigate to this line of code:

    Code:
    case 9190:
    Right under that there should be an if-statement that teleports you somewhere.

    You have two options now with this piece of code we are going to insert.

    Code:
    				 if (c.teleAction == 45) {
    					//tormented demons
    					c.getPA().spellTeleport(2717, 9802, 0);
                                                                    c.sendMessage("You teleport to the Tormented Demons chamber!");
    First option: if you want to throw it right under the case 9190: you will be using the above code:

    Second option: if you want to put it further into the case you will have to use the else- if statement as shown below.

    Code:
    	} else if (c.teleAction == 45) {
    					//tormented demons
    					c.getPA().spellTeleport(2717, 9802, 0);
                                                                    c.sendMessage("You teleport to the Tormented Demons chamber!");
    Always make sure to close with a "}" or your code will not run.

    Now your probably wondering how do I know the correct case for putting the code in?

    Let me explain...



    When you click an option your server command prompt window should tell you the action button id (if you have server debugging turned ON)

    So clicking that we know that our 5 lines are going to be:



    You can now finish adding your if - statements to the cases going in order from 9190 and down for every chat line.

    And you have learned that the c.teleAction is used to identify which teleport you want to call.

    You may want to make your c.teleAction = -1 at the end of your if statements but it is completely up to you.

    I hope you have learned alot from my tutorial. Thanks for reading!


    Post any Errors/Questions.
    [/SPOIL]

    fix images
    Reply With Quote  
     

  12. #10  
    #1 footwear

    Shoes's Avatar
    Join Date
    Aug 2009
    Age
    27
    Posts
    2,612
    Thanks given
    185
    Thanks received
    255
    Rep Power
    579
    Oldest thing ever, people should know at least this by now


    Spoiler for different picture now:
    Reply With Quote  
     

Page 1 of 3 123 LastLast

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. Replies: 10
    Last Post: 10-27-2009, 10:27 PM
  2. Replies: 4
    Last Post: 10-27-2009, 03:31 AM
  3. attacking multiple npc's(chinchompas)
    By NICKname in forum Help
    Replies: 3
    Last Post: 05-25-2009, 01:49 AM
  4. ItemOnItem DFS - Multiple Options
    By Tonypker in forum Tutorials
    Replies: 12
    Last Post: 05-14-2009, 11:32 PM
  5. Multiple teleporting options
    By ~Dark~ in forum Help
    Replies: 1
    Last Post: 04-24-2009, 01:15 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
  •