Jump to content
  • 0

[Question]Teleport


Question

Posted

Hey!

I have a Question.

I want make a zone, and i want to added a another item, no adena.

For example a player, must to have 1 GB for teleport.

 

 

3 answers to this question

Recommended Posts

  • 0
Posted

Create new zone type, in onEnter add check if player inventory contains item with id X, if yes do nothing (allow him to enter) if not - teleport him to nearest village.

  • 0
Posted

By using brain, and some own effort (...)

 

Create new type: ItemZone.java (inside zone/types package)

 

public class ItemZone extends L2ZoneType 
{
private int _item = 0;

public ItemZone(int id)
{
	super(id);
}

@Override
public void setParameter(String name, String value)
{
	if (name.equals("itemId")) 
		_item = Integer.parseInt(value);
	else super.setParameter(name, value);
}

@Override
protected void onEnter(L2Character character) 
{
	if (character instanceof L2PcInstance)
	{
		if(((L2PcInstance)character).getInventory().getItemsByItemId(_item).size() == 0)
		{
                character.sendMessage("You dont have required items to enter!");
			character.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
	        character.teleToLocation(MapRegionTable.TeleportWhereType.Town);
		}
	}
}

@Override
protected void onExit(L2Character character) {}

@Override 
public void onDieInside(L2Character character) {}

@Override 
public void onReviveInside(L2Character character) {}
}

 

Then create new zone in zones.xml (datapack) - dont even dare to ask how to do it, it was explained plenty of times. Create new zone with this name, with special parametr.

 

<stat name="itemId" val="X"/>

 

Done, 10 minutes of work - next time use search and put some own effort.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...