Jump to content
  • 0

Question

Posted (edited)

http://imgur.com/a/APPzF

 

I added this MOD on my server, however I have a problem; When clicking where the player wants to go, he is teleported directly, the bar with the "Ok" and "Cancel" buttons only appears after the player has already been teleported. Should any part of the code be absent?

 

Config.java

 

 

public static boolean TELEPORTER_ENABLE;
public static FastList<Integer> ACCEPTED_TELEPORTERS = new FastList<>();


TELEPORTER_ENABLE = Boolean.valueOf(p.getProperty("EnableTeleporter", "false")).booleanValue();
if (TELEPORTER_ENABLE)
			{
			     ACCEPTED_TELEPORTERS = new FastList<>();
				 for (String type : p.getProperty("AcceptedTeleportersId", "30080").split(",")) {
			     ACCEPTED_TELEPORTERS.add(Integer.valueOf(type));
				}
			}

 

 

 

config.properties

 

 

# ================================================================
#                       Teleporter System
# ================================================================
# Teleporter com timer
# NOTA: adc systemmsg 2155 para funcionar
# Ativar timmer teleporter
EnableTeleporter = True
# Ativar Id teleporters?
AcceptedTeleportersId = 30080
# Systemmsg ID
MessageID = 2155 

 

 

 

L2TeleporterInstance.java (In the doTeleport method)

 

 

if ((Config.TELEPORTER_ENABLE) && (Config.ACCEPTED_TELEPORTERS.contains(Integer.valueOf(getTemplate().getNpcId()))))
		    {
		        ConfirmDlg confirm = new ConfirmDlg(SystemMessageId.S1_REQUEST_TELEPORT_TO_S2_DO_YOU_ACCEPT.getId());
		        confirm.addString(getTemplate().getName());
		        confirm.addZoneName(list.getLocX(), list.getLocY(), list.getLocZ());
		        confirm.addTime(15000);
		        confirm.addRequesterId(player.getObjectId());
		        int[] cords = { list.getLocX(), list.getLocY(), list.getLocZ() };
		        player.addTeleporterCoords(cords);
		        player.sendPacket(confirm);
		    }

 

 

 

ConfirmDlg.java

 

 

if (_time != 0)
writeD(_time);
if (_requesterId != 0)
writeD(_requesterId);

+if (_time > 0)
+getClient().getActiveChar().addConfirmDlgRequestTime(_requesterId, _time);
}
} 

 

 

 

DlgAnswer.java

 

 

final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
return;

+Long answerTime = getClient().getActiveChar().getConfirmDlgRequestTime(this._requestId);
+if ((this._answer == 1) && (answerTime != null) && (System.currentTimeMillis() > answerTime.longValue())) {
 +this._answer = 0;
+}
+getClient().getActiveChar().removeConfirmDlgRequestTime(this._requestId);
+if (this._messageId == SystemMessageId.S1_REQUEST_TELEPORT_TO_S2_DO_YOU_ACCEPT.getId())
+{
+if ((activeChar.getTeleporterCoords() != null) && (this._answer != 0))
+{
      +activeChar.teleToLocation(activeChar.getTeleporterCoords()[0], activeChar.getTeleporterCoords()[1], activeChar.getTeleporterCoords()[2]);
       +activeChar.addTeleporterCoords(null);
+}
+}
   
if (Config.DEBUG)
LOGGER.debug(getType() + ": Answer acepted. Message ID " + _messageId + ", asnwer " + _answer + ", unknown field " + _requestId);

+if (_answer == 1 && answerTime != null && System.currentTimeMillis() > answerTime)
+{
+_answer = 0;
+}
+getClient().getActiveChar().removeConfirmDlgRequestTime(_requestId);

 

 

 

 

L2PcInstance.java

 

 

private int[] TELEPORTER_COORDS;    

	private final HashMap<Integer, Long> confirmDlgRequests = new HashMap<>();
	    
	public void addConfirmDlgRequestTime(int requestId, int time)
	{
	   this.confirmDlgRequests.put(Integer.valueOf(requestId), Long.valueOf(System.currentTimeMillis() + time + 2000L));
	}
	    
	public Long getConfirmDlgRequestTime(int requestId)
	{
	   return this.confirmDlgRequests.get(Integer.valueOf(requestId));
	}
	    
	public void removeConfirmDlgRequestTime(int requestId)
	{
	   this.confirmDlgRequests.remove(Integer.valueOf(requestId));
	}
	    
	public void addTeleporterCoords(int[] cords)
	{
	   this.TELEPORTER_COORDS = cords;
	}
	    
	public int[] getTeleporterCoords()
	{
	   return this.TELEPORTER_COORDS;
	}

 

 

 

SystemMessageId.java

 

 

         /**
	 * ID: 2155<br>
	 * Message: $s1 request teleport to $s2. Do you accept?
	 */
	S1_REQUEST_TELEPORT_TO_S2_DO_YOU_ACCEPT(2155), 

 

 

 

CLIENT:

 

System/systemmsg-e.dat

 

 

2155	1	a,Would you like to teleport to $s2. Do you accept?\0	0	79	9B	B0	FF	a,	a,	0	0	0	0	0	a,	a,popup\0

 

 

Edited by L2shaken
  • Thanks 1

2 answers to this question

Recommended Posts

  • 0
Posted

Someone can write it properly? w/o config or extra msg.

 

I tried to do it similar to summon friend at dlgAnswer w/o using using all the above but i failed cause i'm newbie.

 

Plx someone write it properly i know it's just 5 lines in 3 files.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • L2Elixir – Patch 4 Is Live!   We’re working non-stop, day and night, to deliver the best possible quality and bring back what made L2Elixir special. This project is built with passion, not shortcuts — for the old-school players who remember, and the new ones who want to experience it properly. Thank you for being part of the journey. Together, we’re making L2Elixir great again ❤️ The legends never fade.    ⚙️ General Enabled Class Change service (same class type only) ALT + B → Services → Character Development Enabled Shift + Click on Treasure Chests Players can now identify real chests (Adena, scroll drops) and use Key / Unlock Event deaths now cancel only debuffs, All self buffs are preserved, fixes issues with Root and similar effects Bladedancer class can now log in even when Max Clients (2) is reached. Since an active Bladedancer is not available for every damage dealer and some players tried to abuse this via VPN or a second PC, this feature was added to keep things fair. protections applies, requires testing!    🎒 Items Crystallizing enchanted items now gives the correct increased crystal amount (retail-like behavior) Removed Agathion Seal Bracelet: Rudolph from Santa rewards (Gracia Final item) Added Dualsword Craft Stamp into Milestone Exchange list    🧙 Skills Fixed Banish Undead lethal chance Hot Springs Malaria and similar effects now level up faster while being attacked
    • thats new SEO level tricks you know nothing of noob - bottom line: exposed.
    • Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc. That's his mail address evgesha.nrnr@gmail.com , stay away!   @Atom @Celestine
    • Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc. That's his mail address evgesha.nrnr@gmail.com , stay away! @Celestine @Atom
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock