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.

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


×
×
  • 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