The most basic thing but too many people forget/Don't know the dialoguehandler part so it may reduce some of the dialogue help threads
Good job if it does help anyone
|
This might has released before, or really easy or anything , but i just feel like to help beginners to try to make a simple dialogue with an object.
I made a simple skilling dialogue , its working... but maybe you want to add more options or anything to it ... and change the teleports etc..
Okay, first we have to make a class at :
src\com\rs\game\player\dialogues
name itkilling.java
Code:package com.rs.game.player.dialogues; import com.rs.Settings; import com.rs.cache.loaders.NPCDefinitions; import com.rs.game.WorldTile; import com.rs.game.minigames.CastleWars; import com.rs.game.player.Skills; import com.rs.game.player.content.Magic; import com.rs.game.player.controlers.FightCaves; import com.rs.game.player.controlers.FightKiln; public class Skilling extends Dialogue { //credits to joseph2005h @Override public void start() { sendDialogue( "<col=98CB46>Would you like to use skilling teleports?"); } @Override public void run(int interfaceId, int componentId) { if (stage == -1) { sendEntityDialogue(SEND_1_TEXT_CHAT, new String[] { player.getDisplayName(), "Sure, why not." }, IS_PLAYER, player.getIndex(), 9827); stage = 1; } if (stage == 1) { sendOptionsDialogue("What would you like train?", "Magic", "Herblore", "Firemaking", "Agility", "Mining"); stage = 2; } if (stage ==2){ if (componentId == OPTION_1){ //Magic Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3094, 3502, 0)); } if (componentId == OPTION_2){ //Herblore Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3094, 3502, 0)); } } if (componentId == OPTION_3){ //firemaking Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(1701, 5600, 0)); } if (componentId == OPTION_4){ stage = 3; sendOptionsDialogue("Where would you like to go?", "barbarian", "Gnome training"); } if(stage == 3){ if (componentId == OPTION_1){ Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3094, 3502, 0)); } else if (componentId == OPTION_2){ Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3094, 3502, 0)); } } if(componentId == OPTION_5){ stage = 4;} if (stage == 4){ sendOptionsDialogue("Where would you like to go?", "Desert camp Mining", "Mining guild");} if(componentId == OPTION_1){ Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3300, 3313, 0)); } if(componentId == OPTION_2){ Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3038, 9737, 0)); } } @Override public void finish() { // TODO Auto-generated method stub } }
Now , we have the dialogue .. but we need something that will start the dialogue.
to do that we go to
src\com\rs\net\decoders\handlers
open objecthandler.java
now open dialoguehandler:Code:else if (id == put the object ID you want) player.getDialogueManager().startDialogue("Skilling");
add to it :
Code:handledDialogues.put("Skilling", (Class<Dialogue>) Class.forName(Skilling.class.getCanonicalName()));
Now you have a simple dialogue that starts when you click on an object
enjoy
The most basic thing but too many people forget/Don't know the dialoguehandler part so it may reduce some of the dialogue help threads
Good job if it does help anyone
Hi i got everything to work correctly with compiling and such except for one thing...
When i tried adding this code: handledDialogues.put("Skilling", (Class<Dialogue>) Class.forName(Skilling.class.getCanonicalName()));
i got 1 error and i've tried to switch it around but nothing seems to work, so could you help me out by telling me how to fix this error. Apparently it cannot find the symbol??
::EDIT:: Never mind lol i fixed it.
Okay, say if i wanted to make a new dialogue after I've already got Skilling.Java, would i make a new class called ermmm for instance, Darkportal.Java?
Also thanks, this helped alot
you should use eclipse auto fixes this error...
Use eclipse.
Basic tbh, but good job
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |