try removingCode:public void start() { sendDialogue("This portal is used to teleport players to the market."); stage = 1; }thereCode:stage = 1;
|
Hello,
Tried having a dialog for an object, but the dialog will not continue after the first sendDialog in the start method. Apparently, the last dialogue is null, but I tried setting other dialogs before it and could not get it to work. (By other dialogs, I am referring to using the "sendDialog" method in the Dialogue class.
Any help is appreciated, thank you.Code:package com.rs.game.player.dialogues; import com.rs.Settings; import com.rs.StaticIds; import com.rs.game.WorldTile; public class MarketPortal extends Dialogue { @Override public void start() { sendDialogue("This portal is used to teleport players to the market."); stage = 1; } public void run(int interfaceId, int componentId) { if(stage == -1) { sendOptionsDialogue("Would you like to visit the market?", "Yes", "No"); stage = 1; } else if (stage == 1) { if (componentId == OPTION_1) { player.teleportPlayer(Settings.MARKET_LOCATION.getX(), Settings.MARKET_LOCATION.getY(), 0); player.send_message("Welcome to the market!"); } else { player.getInterfaceManager().closeChatBoxInterface(); end(); } } else if(stage == 2) { player.getInterfaceManager().closeChatBoxInterface(); end(); } } @Override public void finish() { } }
try removingCode:public void start() { sendDialogue("This portal is used to teleport players to the market."); stage = 1; }thereCode:stage = 1;
you have two options yes and no.
that will doCode:if (componentId == OPTION_1) { } else if (componentId == OPTION_2) { }
Code:else if (componentId == OPTION_2) { player.getInterfaceManager().closeChatBoxInterface(); end(); }
and delete stage == -1 and change it into 1.
finallyCode:if stage ==-1
Code:package com.rs.game.player.dialogues; import com.rs.Settings; import com.rs.StaticIds; import com.rs.game.WorldTile; public class MarketPortal extends Dialogue { @Override public void start() { sendDialogue("This portal is used to teleport players to the market."); stage = 1; } public void run(int interfaceId, int componentId) { if(stage == 1) { sendOptionsDialogue("Would you like to visit the market?", "Yes", "No"); stage = 2; } else if (stage == 2) { if (componentId == OPTION_1) { player.teleportPlayer(Settings.MARKET_LOCATION.getX(), Settings.MARKET_LOCATION.getY(), 0); player.send_message("Welcome to the market!"); } else if (componentId == OPTION_2) { player.getInterfaceManager().closeChatBoxInterface(); end(); } } } @Override public void finish() { } }
also make sure you have it in the dialogue handler.Code:package com.rs.game.player.dialogues; import com.rs.Settings; import com.rs.StaticIds; import com.rs.game.WorldTile; public class MarketPortal extends Dialogue { /** * Starts the dialogue */ public MarketPortal() { } @Override public void start() { sendDialogue("This portal is used to teleport players to the market."); } /** * Runs the dialogue */ @Override public void run(int interfaceId, int componentId) { if (stage == -1) { stage = 0; sendOptionsDialogue("Would you like to visit the market?", "Yes", "No"); } else if (stage == 0) { if (componentId == OPTION_1) { player.teleportPlayer(Settings.MARKET_LOCATION.getX(), Settings.MARKET_LOCATION.getY(), 0); player.send_message("Welcome to the market!"); end(); } else { player.getInterfaceManager().closeChatBoxInterface(); end(); } } } @Override public void finish() { } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |