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

    • (3241-100)/9 = 349 online xD     WHAT I WILL SEE ON NEW SEASON ? *Free VIP characters for everyone for first 3 days after opening ! Unique augmentation trade/sell system (NEW PATCH V3.2). Improved server stability. No more lagg / dc. Pvp map area HIDE Names/clans unique system. Big changes on augmentation system.  rotfl Lucky fortune monsters on levelling area with 10min spawn. Also we will try to push longer seasons ever !  HAHAHAHAHAHA XD Increased giran trading area for sell. New raid boss events in coliseum. Fixed reflect damage skills. New raid boss banshee. Fixed pvp area flag issues. Fixed castle siege pray issues. New pvp map in sea of spores. Increased all mob drops rate by +20%. And much more...   Augment diammond 100% 3x winter xDD   And now the best part   HAHAHAH 1-10 random level LS Augment Also we will try to push longer seasons ever !  HAHAHAHAHAHA XD   GRAND START FROM - 15/08/2025, FRIDAY, 20:00 +3 GMT ! GRAND OPENING FROM - 10/10/2025, FRIDAY, 20:00 +3 GRAND OPENING FROM - 05 DECEMBER 2025, FRIDAY, 20:00 +2 GMT ! GRAND OPENING FROM - 12/052025, FRIDAY, 20:00 +3 GMT ! GRAND OPENING FROM - 23 JANUARY 2026, FRIDAY, 20:00 +2 GMT ! WIPE ! NEW SEASON GRAND OPENING FROM TODAY ! - 23/01/2026, FRIDAY, 20:00 +3 GMT ! OPENING TODAY !!! FROM - 06/03/2026, FRIDAY, 20:00 +3 GMT !   1. When wipe?  2. When will there be any response to the allegations? 3. When will they stop deceiving players with the actual number of players online? 4. When change server name to L2][Wipe the best waste Time][Money?
    • Don't spam my post again. Do you need attention? That guy doesn't work at L2Devs, he's not a programmer, and I've never spoken to him. You should respond to the people you scammed. Regards!
    • “WRONG EMAIL – AND EVERYTHING FALLS APART.” ▪ Requests are different. Sometimes a task takes three days, sometimes thirty minutes. ▪ Recently a regular client contacted us. The account had one e-mail, but another one was required for a specific service. ▪ The screenshot was sent immediately. Task – carefully replace the e-mail in the document so that everything looks natural and leaves no editing traces. ▪ Small details like this are often underestimated. › What usually happens: – one symbol in the e-mail doesn’t match – the system starts checking metadata – questions appear about the file origin – the document goes to additional verification ▪ We simply did it properly: the e-mail matches, the file structure remained intact, the document looks original. ▪ Sometimes a good result is not “magic”, but precision in details. ▪ If your document were checked right now – are you sure there are no small details that could ruin everything? › TG: https://t.me/mustang_service ( https:// t.me/ mustang_service ) › Channel: https://t.me/+JPpJCETg-xM1NjNl ( https:// t.me/ +JPpJCETg-xM1NjNl ) #documentdesign #verification #documents #case #antifraud
    • Skylord  = L2Gold.eu ;   Skylord is the programmer at L2Devs. Look what he posted in my thread. I reported him, and they automatically deleted his post and closed my thread.   They need to trick people into buying this garbage.   You can safely use this extender:   https://maxcheaters.com/topic/253977-%F0%9F%94%A5-l2ext-custom-interlude-vang-%E2%80%93-2026-release/  
    • 💙 PRIDE ESSENCE X1  ✅ Start: 14.03.2026  ✅ UPDATE: SAMURAI CROW  ✅ ONLINE: 2000+  💜 NO P2W / BIG CLANS / INTERNATIONAL COMMUNITY / STAGE SYSTEM  🎮 Discord bonus: https://discord.gg/prideessence Pride Essence Official Server Wiki Here you can find all features, systems, and detailed information to fully understand the server.   - General Features - https://prideessence.club/general-features - Road Map - https://prideessence.club/roadmap/ - Class Balance – 14/03 - https://prideessence.club/class-balance-14-03/ - Referral System - https://prideessence.club/referral-system/ - Party Synergy System - https://prideessence.club/party-synergy-system/ - Dual Class System - https://prideessence.club/dual-class-system-3/ - Premium Account - https://prideessence.club/premium-account/ - Game Store - https://prideessence.club/game-store/ - L-Coin Store - https://prideessence.club/l-coin-store/ - Command Channel Skill Availability - https://prideessence.club/command-channel-skill-availability/ - Clan DKP System - https://prideessence.club/clan-dkp-system/ - Target Priority System - https://prideessence.club/target-priority-system/ - Skins - https://prideessence.club/skins/ - Players Inspect - https://prideessence.club/players-inspect/ - Gear Score Ranking - https://prideessence.club/gear-score-ranking/ - Guaranteed Enchant System - https://prideessence.club/guaranteed-enchant-system/ - Account Shield - https://prideessence.club/account-shield/ - VIP Level Ranking - https://prideessence.club/vip-level-ranking/ - Tournament - https://prideessence.club/tournament-2/ - Fortress Siege - https://prideessence.club/fortress-siege/ - Olympiad - https://prideessence.club/olympiad/ - Enchant and Compound Limit - https://prideessence.club/enchant-and-compound-limit/ - Enchant Rates - https://prideessence.club/enchant-rates/ - Pride World Marketplace - https://prideessence.club/pride-world-marketplace/ - Raid Boss Lootbox - https://prideessence.club/raid-boss-lootbox/
  • 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..