Jump to content

Recommended Posts

Posted

 i want to Modification this bata npc code to make players pay for this Services

 

pay item id 57 

 

 

package l2f.gameserver.model.instances;

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

import l2f.commons.dbutils.DbUtils;
import l2f.gameserver.database.DatabaseFactory;
import l2f.gameserver.model.Player;
import l2f.gameserver.model.entity.olympiad.Olympiad;
import l2f.gameserver.network.serverpackets.L2GameServerPacket;
import l2f.gameserver.network.serverpackets.PledgeShowInfoUpdate;
import l2f.gameserver.network.serverpackets.SkillList;
import l2f.gameserver.network.serverpackets.UserInfo;
import l2f.gameserver.tables.SkillTable;
import l2f.gameserver.templates.npc.NpcTemplate;
import l2f.gameserver.utils.Log;

public final class BetaNPCInstance extends NpcInstance
{
	/**
	 * Author Ady
	 */
	private static final long serialVersionUID = 5938813598479742068L;

	public BetaNPCInstance(int objectId, NpcTemplate template)
	{
		super(objectId, template);
	}
	
	@Override
	public void onBypassFeedback(Player player, String command)
	{
		if (!canBypassCheck(player, this))
		{
			return;
		}
		if (command.equalsIgnoreCase("change_sex"))
		{
			Connection con = null;
			PreparedStatement offline = null;
			try
			{
				con = DatabaseFactory.getInstance().getConnection();
				offline = con.prepareStatement("UPDATE characters SET sex = ? WHERE obj_Id = ?");
				offline.setInt(1, player.getSex() == 1 ? 0 : 1);
				offline.setInt(2, player.getObjectId());
				offline.executeUpdate();
			}
			catch (Exception e)
			{
				e.printStackTrace();
				return;
			}
		finally
			{
				DbUtils.closeQuietly(con, offline);
			}
			
			player.changeSex();
			player.sendMessage("Your gender has been changed !!");
			Log.add(new StringBuilder().append("Character ").append(player).append("  changed sex to ").append(player.getSex() == 1 ? "male" : "female").toString(), "renames");
		}
		else if (command.equalsIgnoreCase("add_clan_reputation"))
		{
			if (player.getClan() != null)
			{
				player.getClan().incReputation(10000, false, "BetaNpc");
				player.getClan().broadcastToOnlineMembers(new L2GameServerPacket[]
				{
					new PledgeShowInfoUpdate(player.getClan())
				});
				player.sendMessage("Your clan received 10 000 clan reputation!");
			}
			else
			{
				player.sendMessage("You don't have clan to use this feature!");
			}
		}
		else if (command.equalsIgnoreCase("add_exp_sp"))
		{
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
			player.addExpAndSp(999999999L, 999999999L);
		}
		else if (command.equalsIgnoreCase("add_fame"))
		{
			player.setFame(player.getFame() + 10000, "BetaNpc");
			player.sendPacket(new UserInfo(player));
			player.sendMessage("You received 10.000 fame points !");
		}
		else if (command.equalsIgnoreCase("give_noblesse"))
		{
			if (!player.isNoble())
			{
				Olympiad.addNoble(player.getPlayer());
				player.getPlayer().setNoble(true);
				player.getPlayer().updatePledgeClass();
				player.getPlayer().updateNobleSkills();
				player.getPlayer().sendPacket(new SkillList(player.getPlayer()));
				player.getPlayer().broadcastUserInfo(true);
				player.getInventory().addItem(7694, 1L, "nobleTiara");
				player.sendMessage("Congratulations! You gained noblesse rank.");
				player.broadcastUserInfo(true);
			}
			else if (player.isNoble())
			{
				player.sendMessage("You already have noblesse rank !");
			}
		}
		else if (command.equalsIgnoreCase("give_hero"))
		{
			if (!player.isHero())
			{
				player.setHero(true);
				player.updatePledgeClass();
				player.addSkill(SkillTable.getInstance().getInfo(395, 1));
				player.addSkill(SkillTable.getInstance().getInfo(396, 1));
				player.addSkill(SkillTable.getInstance().getInfo(1374, 1));
				player.addSkill(SkillTable.getInstance().getInfo(1375, 1));
				player.addSkill(SkillTable.getInstance().getInfo(1376, 1));
				player.sendPacket(new SkillList(player));
				player.getPlayer().broadcastUserInfo(true);
				player.sendMessage("Congratulations! You gained hero rank.");
				player.broadcastUserInfo(true);
			}
			else if (player.isNoble())
			{
				player.sendMessage("You already have hero rank !");
			}
		}
		else
		{
			super.onBypassFeedback(player, command);
		}
	}
	
	@Override
	public boolean isNpc()
	{
		return true;
	}
	
}

 

Posted (edited)

You should first use a method to check if player has enough adena and return message if insufficient.
Then at end of script another method should consume(remove) the adena and return message about the adena consumption.
You should do that for each option separately.
If u want it more complex than that.
You should create a config file and use a boolean to enable feature and string for adena amount per option.

Edited by Cherish
  • Vision locked this topic
Guest
This topic is now closed to further replies.


  • Posts

    • Thank you for sharing this with us!   
    • Server L2 Reborn x1 C4 Signature   I am looking to buy a client modification, such as l2.ini or other possible files on the server The server uses SmartGuard protection, but as far as I understand, not all files are checked before launch   Сервер L2 Reborn x1 C4 Signature Ищу возможность приобрести модификацию клиента, например l2.ini или других возможных файлов на сервере. На сервере установлена защита SmartGuard, но, насколько я понимаю, не все файлы проверяются перед запуском. _______________________________________________________________ https://join.skype.com/invite/C72FPnumKn7e - Skype https://t.me/rebornclient - Telegram  
    • 🎉 The Big Moment Has Arrived! 🎉   Tomorrow is the day we've all been waiting for! L2KvN is opening its gates again, and we are waiting for you all to start this epic journey together! 🌟   🗓️ Date: November 17, 2024 ⏰ Time: 20:00 Greece (Athens), Russia (Moscow), Lithuania 18:00 United Kingdom 13:00 USA (Eastern Time), Argentina 10:00 AM US (Pacific Time) 14:00 Brazil 05:00 Russia (Vladivostok) ✨ What awaits you: ⚔️ Unique gameplay and intense PvP encounters 🎁 Exclusive events and rich rewards 👥 Live community and instant support 📈 Continuous upgrades for the ultimate experience 💬 Bring your friends, organize your teams, and get ready to conquer the world of L2KvN! 📢 Don't forget: We are here to help you! If you are a Clan Leader or Streamer, please contact us to become a part of this great community. 🛡️ The countdown is over – tomorrow we start! The game is just beginning… again! 💪   🌍 Dating in the world of L2KvN!
    • Very cool.   Unfortunately, I can't afford this fee.
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt  
  • Topics

×
×
  • Create New...