Jump to content
  • 0

[HELP] How to add line to remove weapons in Code Java ?


Question

Posted

how do I add a command line when to remove the member VIP also remove a weapon that the inventory?

 

see the code...

 

package com.l2j.gameserver.handler.admincommandhandlers;

import java.sql.Connection;
import java.sql.PreparedStatement;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.l2j.L2DatabaseFactory;
import com.l2j.gameserver.Announcements;
import com.l2j.gameserver.datatables.GmListTable;
import com.l2j.gameserver.handler.IAdminCommandHandler;
import com.l2j.gameserver.model.L2Object;
import com.l2j.gameserver.model.actor.instance.L2PcInstance;
import com.l2j.gameserver.network.serverpackets.SocialAction;

public class AdminVip implements IAdminCommandHandler
{
private static String[]		ADMIN_COMMANDS	=
											{ "admin_setvip" };
private final static Log	_log			= LogFactory.getLog(AdminVip.class.getName());

public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
	if (activeChar == null)
		return false;

	if (command.startsWith("admin_setvip"))
	{
		L2Object target = activeChar.getTarget();

		if (target instanceof L2PcInstance)
		{
			L2PcInstance targetPlayer = (L2PcInstance) target;
			boolean newVip = !targetPlayer.isCharViP();

			if (newVip)
			{
				targetPlayer.setCharViP(true);
				targetPlayer.updateNameTitleColor();
				updateDatabase(activeChar, true);
				sendMessages(true, targetPlayer, activeChar, true, true);
				targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16)); 
				targetPlayer.broadcastUserInfo();
			}
			else
			{
					targetPlayer.setCharViP(false);
				targetPlayer.updateNameTitleColor();
				updateDatabase(activeChar, false);
				sendMessages(false, targetPlayer, activeChar, true, true);
				targetPlayer.broadcastUserInfo();
			}
		}
		else
		{
			activeChar.sendMessage("Impossible to set a non Player Target as VIP.");
			_log.info("GM: " + activeChar.getName() + " is trying to set a non Player Target as VIP.");
			return false;
		}
	}
	return true;
}

private void sendMessages(boolean fornewVip, L2PcInstance player, L2PcInstance gm, boolean announce, boolean notifyGmList)
{
	if (fornewVip)
	{
		player.sendMessage(gm.getName() + " has granted VIP Status for you!");
		gm.sendMessage("You've granted VIP Status for " + player.getName());

		if (announce)
			Announcements.getInstance().announceToAll(player.getName() + " has received VIP Status!");

		if (notifyGmList)
			GmListTable.broadcastMessageToGMs("Warn: " + gm.getName() + " has Set " + player.getName() + " as VIP !");
	}
	else
	{
		player.sendMessage(gm.getName() + " has revoked VIP Status from you!");
		gm.sendMessage("You've revoked VIP Status from " + player.getName());

		if (announce)
			Announcements.getInstance().announceToAll(player.getName() + " has lost VIP Status!");

		if (notifyGmList)
			GmListTable.broadcastMessageToGMs("Warn: " + gm.getName() + " has removed VIP Status of player" + player.getName());
	}
}

/**
 *
 * @param activeChar
 * @param newDonator
 */
private void updateDatabase(L2PcInstance player, boolean newVIP)
{
	Connection con = null;
	try
	{
		// prevents any NPE.
		// ----------------
		if (player == null)
			return;

		// Database Connection
		//--------------------------------
		con = L2DatabaseFactory.getInstance().getConnection();
		PreparedStatement stmt = con.prepareStatement(newVIP ? INSERT_DATA : DEL_DATA);

		// if it is a new donator insert proper data
		// --------------------------------------------
		if (newVIP)
		{
			stmt.setInt(1, player.getObjectId());
			stmt.setString(2, player.getName());
			stmt.setInt(3, player.isHero() ? 1 : 0);
			stmt.setInt(4, player.isNoble() ? 1 : 0);
			stmt.setInt(5, player.isDonator() ? 1 : 0);
			stmt.setInt(6, 1);
			stmt.execute();
			stmt.close();
		}
		else
		// deletes from database
		{
			stmt.setInt(1, player.getObjectId());
			stmt.execute();
			stmt.close();
		}
	}
	catch (Exception e)
	{
		_log.error("Error: could not update database: ", e);
	}
	finally
	{
		try
		{
			con.close();
		}
		catch (Exception e)
		{
			_log.error("Error: could not update database: ", e);
		}
	}
}

// Updates That Will be Executed by MySQL
// ----------------------------------------
String	INSERT_DATA	= "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, vip) VALUES (?,?,?,?,?,?)";
String	DEL_DATA	= "UPDATE characters_custom_data SET vip = 0 WHERE obj_Id=?";

/**
 * @return
 */
public String[] getAdminCommandList()
{
	return ADMIN_COMMANDS;
}
}

 

thxx

4 answers to this question

Recommended Posts

  • 0
Posted

Sorry you have to speak better english.

 

[Offtopic]

Se quiseres escreve em brazileiro que eu leio,o teu inglês é ilegivel

  • 0
Posted

Sorry i use translator!

 

Vamos la, estou querendo adicionar um linha de comando para quando eu remover o membro VIP remova também um certo item que esta no inventario dele, uma Weapon por exemplo.

 

Postei o código do AdminCommand //setvip no post antigo.

  • 0
Posted

Sorry i use translator!

 

Vamos la, estou querendo adicionar um linha de comando para quando eu remover o membro VIP remova também um certo item que esta no inventario dele, uma Weapon por exemplo.

 

Postei o código do AdminCommand //setvip no post antigo.

Just use L2PcInstance player = null; player.getInventory().deleteItem(itemId);

I don't have eclipse on this PC so the method names might be wrong,but thats basically it.

  • 0
Posted

In setvip, something like (example of my aio systtem):

 

_player.getInventory().addItem("", Config.AIO_ITEMID, 1, _player, null);

 

and to remove

 

_player.getInventory().destroyItemByItemId("", Config.AIO_ITEMID, 1, _player, null);
_player.getWarehouse().destroyItemByItemId("", Config.AIO_ITEMID, 1, _player, null);

 

WH check in case, he put the item into wh.

Guest
This topic is now closed to further replies.
  • Posts

    • You should buy it then I’ll make a discount  
    • Hi everyone,   In 2014, I completely stepped away from developing L2 servers and doing L2J-related work. Since then, I’ve only opened this server about once a year and helped a few servers and individuals for free. I haven’t taken on any paid L2J work since then.   LINEAGE2.GOLD is a project that has reached about Season 6. The first season launched at the end of 2020 and was a fully rebuilt Gold-style server on the Classic client (protocol 110). It featured many custom systems and enhancements. After several seasons, I decided to abandon the Mobius-based project and move to Lucera, as my goal was to get as close as possible to Interlude PTS behavior while still staying on the L2J platform.   The current project was once again completely rebuilt, this time on the Essence client (protocol 306), and is based on Lucera. Because of that, acquiring a license from Deazer is required.   My Lucera extender includes, but is not limited to: Formulas.java Basic anti-bot detection, which proved quite effective, we caught most Adrenaline users using relatively simple server-side logic, logged them, and took staff action. Simple admin account lookup commands based on IP, HWID, and similar identifiers. In-game Captcha via https://lineage2.gold/code, protected by Cloudflare, including admin commands for blacklisting based on aggression levels and whitelisting. Additional admin tools such as Auto-Play status checks, Enchanted Hero Weapon live sync, force add/remove clans from castle sieges, item listeners for live item monitoring, and more. A fully rewritten Auto-Play system with support for ExAutoPlaySetting, while still using the Auto-Play UI wheel, featuring: Debuff Efficiency Party Leader Assist Respectful Hunting Healer AI Target Mode Range Mode Summoner buff support Dwarf mechanics Reworked EffectDispelEffects to restore buffs after Cancellation. Raid Bomb item support. Reworked CronZoneSwitcher. Prime Time Raid Respawn Service. Community Board features such as Top rankings and RB/Epic status. Custom systems for Noblesse, Subclasses, support-class rewards, and much more.   Depending on the deal, the project can include: The lineage2.gold domain The website built on the Laravel PHP framework The server’s Discord Client Interface source Server files and extender source The server database (excluding private data such as emails and passwords)   I’m primarily looking for a serious team to continue the project, as it would be a shame to see this work abandoned. This is not cheap. You can DM me with offers. If you’re wondering why I’m doing this: I’ve felt a clear lack of appreciation from the L2 community, and I’m not interested in doing charity work for people who don’t deserve it. I’m simply not someone who tolerates BS. Server Info: https://lineage2.gold/info Server for test: https://lineage2.gold/download Over 110 videos YouTube playlist: https://www.youtube.com/watch?v=HO7BZaxUv2U&list=PLD9WZ0Nj-zstZaYeWxAxTKbX7ia2M_DUu&index=113
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

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