Jump to content

Recommended Posts

Posted (edited)
package mods.LevelUpReward;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.w3c.dom.Node;

import com.l2jserver.gameserver.engines.DocumentParser;
import com.l2jserver.gameserver.model.PlayerVariables;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.scripting.scriptengine.events.PlayerLevelChangeEvent;
import com.l2jserver.gameserver.scripting.scriptengine.impl.L2Script;

public final class LevelUpReward extends L2Script
{
	// Misc
	private static final String HTML_PATH = "data/scripts/mods/LevelUpReward/";
	protected static boolean rewardAll = false;
	protected static final Map<Integer, LevelData> REWARDS = new HashMap<>();
	
	private LevelUpReward(String name, String descr)
	{
		super(name, descr);
		addPlayerLevelNotify(null);
		new LevelUpRewardData();
	}
	
	@Override
	public void onPlayerLevelChange(PlayerLevelChangeEvent event)
	{
		final L2PcInstance player = event.getPlayer();
		if (player == null)
		{
			return;
		}
		final int newLevel = event.getNewLevel();
		for (int oldLevel = (rewardAll) ? 1 : (event.getOldLevel() + 1); oldLevel <= newLevel; oldLevel++)
		{
			if (!REWARDS.containsKey(oldLevel))
			{
				continue;
			}
			final PlayerVariables vars = player.getVariables();
			if (vars.getBool("LEVEL_UP_REWARD_" + oldLevel, false))
			{
				continue;
			}
			final LevelData rewards = REWARDS.get(oldLevel);
			for (ItemHolder item : rewards.getItems())
			{
				player.addItem("Quest", item, player, true);
			}
			vars.set("LEVEL_UP_REWARD_" + oldLevel, true);
			if (rewards.getMessage() != "")
			{
				player.sendMessage(rewards.getMessage());
			}
			if (rewards.getHtmlFile() != "")
			{
				final NpcHtmlMessage html = new NpcHtmlMessage(player.getObjectId());
				html.setFile(player.getHtmlPrefix(), HTML_PATH + rewards.getHtmlFile());
				player.sendPacket(html);
			}	
		}
	}
	
	protected final class LevelUpRewardData extends DocumentParser
	{
		public LevelUpRewardData()
		{
			load();
		}
		
		@Override
		public void load()
		{
			parseDatapackFile("data/xml/LevelReward/LevelReward.xml");
		}
		
		@Override
		protected void parseDocument()
		{
			for (Node n = getCurrentDocument().getFirstChild(); n != null; n = n.getNextSibling())
			{
				if ("list".equals(n.getNodeName()))
				{
					for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
					{
						if ("rewards".equals(d.getNodeName()))
						{
							LevelData data = new LevelData();
							for (Node e = d.getFirstChild(); e != null; e = e.getNextSibling())
							{
								if ("item".equals(e.getNodeName()))
								{
									data.addItem(parseInteger(e.getAttributes(), "id"), parseLong(e.getAttributes(), "count"));
								}
							}
							data.setMessage(parseString(d.getAttributes(), "message"));
							data.setHtmlFile(parseString(d.getAttributes(), "htmlFile"));
							REWARDS.put(parseInteger(d.getAttributes(), "level"), data);
						}
					}
					rewardAll = parseBoolean(n.getAttributes(), "rewardAll");
				}
			}
		}
	}
	
	protected final class LevelData
	{
		private String html;
		private final List<ItemHolder> items;
		private String message;
		
		public LevelData()
		{
			html = "";
			items = new ArrayList<>();
			message = "";
		}
		
		public void addItem(int itemId, long itemCount)
		{
			items.add(new ItemHolder(itemId, itemCount));
		}
		
		public void setHtmlFile(String htmlFile)
		{
			html = htmlFile;
		}
		
		public void setMessage(String message)
		{
			this.message = message;
		}
		
		public String getHtmlFile()
		{
			return html;
		}
		
		public List<ItemHolder> getItems()
		{
			return items;
		}
		
		public String getMessage()
		{
			return message;
		}
	}
	
	public static void main(String[] args)
	{
		new LevelUpReward(LevelUpReward.class.getSimpleName(), "mods");
	}
}

This is the mod i got.
I want it to work this way:
Example: When i get lvl 20 i receive one item. Then if i get lvl 20 again i receive it again.
i Want it to give me itens everytime i get lvl 20.. doent matter if i Delevel or something else
It is only working if i relog.
Can someone help me please? this forum is dead?
 

Edited by Tamira
Fix

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


  • Posts

    • Dear friends, we are pleased to announce great news — we are launching our new bot for purchasing and renting virtual numbers for receiving SMS from any services! Are you tired of reused or resold numbers from other platforms? Try our solution! Our service allows you to receive SMS from any major popular services. The list includes more than 200 services! SMS receiving country: USA (+1). Real physical US numbers are used — never previously used on other platforms! Currently, only short-term rental is available. The rental duration for each phone number is shown when purchasing. The cost of each number is also shown next to the service before purchase. You can also receive an additional SMS for your number for the selected service (no extra charge for receiving one more SMS). To quickly find the service you need, you can use the convenient search — just type the name of the service you need and get a number for activation. Available payment methods: cryptocurrencies, bank cards, and balance transfer from our other bots. Thank you for your trust! Active links: Virtual Number Service: Go Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends, we are pleased to announce great news — we are launching our new bot for purchasing and renting virtual numbers for receiving SMS from any services! Are you tired of reused or resold numbers from other platforms? Try our solution! Our service allows you to receive SMS from any major popular services. The list includes more than 200 services! SMS receiving country: USA (+1). Real physical US numbers are used — never previously used on other platforms! Currently, only short-term rental is available. The rental duration for each phone number is shown when purchasing. The cost of each number is also shown next to the service before purchase. You can also receive an additional SMS for your number for the selected service (no extra charge for receiving one more SMS). To quickly find the service you need, you can use the convenient search — just type the name of the service you need and get a number for activation. Available payment methods: cryptocurrencies, bank cards, and balance transfer from our other bots. Thank you for your trust! Active links: Virtual Number Service: Go Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends, we are pleased to announce great news — we are launching our new bot for purchasing and renting virtual numbers for receiving SMS from any services! Are you tired of reused or resold numbers from other platforms? Try our solution! Our service allows you to receive SMS from any major popular services. The list includes more than 200 services! SMS receiving country: USA (+1). Real physical US numbers are used — never previously used on other platforms! Currently, only short-term rental is available. The rental duration for each phone number is shown when purchasing. The cost of each number is also shown next to the service before purchase. You can also receive an additional SMS for your number for the selected service (no extra charge for receiving one more SMS). To quickly find the service you need, you can use the convenient search — just type the name of the service you need and get a number for activation. Available payment methods: cryptocurrencies, bank cards, and balance transfer from our other bots. Thank you for your trust! Active links: Virtual Number Service: Go Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends, we are pleased to announce great news — we are launching our new bot for purchasing and renting virtual numbers for receiving SMS from any services! Are you tired of reused or resold numbers from other platforms? Try our solution! Our service allows you to receive SMS from any major popular services. The list includes more than 200 services! SMS receiving country: USA (+1). Real physical US numbers are used — never previously used on other platforms! Currently, only short-term rental is available. The rental duration for each phone number is shown when purchasing. The cost of each number is also shown next to the service before purchase. You can also receive an additional SMS for your number for the selected service (no extra charge for receiving one more SMS). To quickly find the service you need, you can use the convenient search — just type the name of the service you need and get a number for activation. Available payment methods: cryptocurrencies, bank cards, and balance transfer from our other bots. Thank you for your trust! Active links: Virtual Number Service: Go Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

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