Jump to content

[SHARE] PVP Shop Instance


Orgyilkos

Recommended Posts

Create com.l2jserver.gameserver.model.actor.instance.L2PVPInstance.java

package com.l2jserver.gameserver.model.actor.instance;

import java.util.StringTokenizer;

import com.l2jserver.gameserver.TradeController;
import com.l2jserver.gameserver.model.L2Multisell;
import com.l2jserver.gameserver.model.L2TradeList;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ExBuySellListPacket;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
import com.l2jserver.gameserver.util.StringUtil;

/**
* 
* @author Mentor
* @version 1.1
* @web www.teamsrv.net
*
*/

public class L2PVPInstance extends L2NpcInstance
{
public L2PVPInstance(int objectId, L2NpcTemplate template)
{
	super(objectId, template);
}

@Override
public String getHtmlPath(int npcId, int val)
{
	String pom = "";

	if (val == 0) pom = "" + npcId;
	else pom = npcId + "-" + val;

	return "data/html/PVPMerchant/" + pom + ".htm";
}

protected final void showBuyWindow(L2PcInstance player, int val)
{
	player.tempInventoryDisable();

	L2TradeList list = TradeController.getInstance().getBuyList(val);

	if (list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
		player.sendPacket(new ExBuySellListPacket(player, list, 0, false));
	else
	{
		_log.warning("buylist id:" + val);
	}

	player.sendPacket(ActionFailed.STATIC_PACKET);
}

@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
	StringTokenizer st = new StringTokenizer(command, " ");
	String actualCommand = st.nextToken(); // Get actual command
	int pvp = Integer.parseInt(st.nextToken());
	if (actualCommand.equalsIgnoreCase("Buy") && player.getPvpKills() >= pvp)
	{
		if (st.countTokens() < 1)
			return;

		int val = Integer.parseInt(st.nextToken());
		showBuyWindow(player, val);
	}
	else if (actualCommand.equalsIgnoreCase("Multisell") && player.getPvpKills() >= pvp)
	{
		if (st.countTokens() < 1)
			return;

		int val = Integer.parseInt(st.nextToken());
		L2Multisell.getInstance().separateAndSend(val, player, getNpcId(), false, getCastle().getTaxRate());
	}
	else if (actualCommand.equalsIgnoreCase("Exc_Multisell") && player.getPvpKills() >= pvp)
	{
		if (st.countTokens() < 1)
			return;

		int val = Integer.parseInt(st.nextToken());
		L2Multisell.getInstance().separateAndSend(val, player, getNpcId(), true, getCastle().getTaxRate());
	}
	else
	{
		NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		final StringBuilder html1 = StringUtil.startAppend(2000, 
		"<html><body><font color=\"06ff0a\">PvP Manager:</font><br>	You not enough pvp kills.<br1>You have <font color=\"LEVEL\">",
		String.valueOf(player.getPvpKills()),
		"</font> pvp kills in <font color=\"FF0000\">",
		String.valueOf(pvp),
		"</font> pvp kills.<br><center>Created by <font color=\"06ff0a\">Mentor</font></center></body></html>");
		html.setHtml(html1.toString());
		player.sendPacket(html);
		super.onBypassFeedback(player, command);
	}
}
}

 

NPC:

INSERT INTO `custom_npc` VALUES ('40000', '32226', 'Barika', '1', 'PVP Shop Manager', '1', 'LineageNPC2.K_F1_grand', '11.00', '22.25', '70', 'male', 'L2PVP', '40', '2444', '2444', '0.00', '0.00', '10', '10', '10', '10', '10', '10', '0', '0', '500', '500', '500', '500', '278', '0', '333', '0', '0', null, '0', '28', '120', '0', '0', 'LAST_HIT', 'false');

 

HTML:

Create PVPMerchant directory in data/html.

data/html/PVPMerchant/40000.htm

<html><body>L2PVP Shop Instance By Mentor:<br>

<font color="LEVEL">Npc by Mentor</font><br>

<a action="bypass -h npc_%objectId%_multisell 200 452">Multisell PvP (PVP 200)</a><br1>

<a action="bypass -h npc_%objectId%_exc_multisell 400 452">Exc_Multisell PvP (PVP 400)</a><br1>

<a action="bypass -h npc_%objectId%_buy 0 40000">Buy (PVP 0)</a><br1>

</body></html>

 

<a action="bypass -h npc_%objectId%_multisell PVP_COUNT MULTISELL_ID">Buy Weapon</a>

<a action="bypass -h npc_%objectId%_exc_multisell PVP_COUNT MULTISELL_ID">Buy Weapon</a>

<a action="bypass -h npc_%objectId%_buy PVP_COUNT MERCHANT_BUYLIST_ID">Buy Weapon</a>

 

I tested in L2J (Rev 3900).

Created by Mentor.(me)

[sorry, I bad in Enlish.]

Link to comment
Share on other sites

Well it's the same but the code is different so i'm gonna let both and let the choice to the members.

Link to comment
Share on other sites

  • 3 months later...
  • 4 weeks later...

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
Reply to this topic...

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

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