Jump to content
  • 0

Buffer Question


Question

Posted (edited)

First of all, I want to mention that I am a beginner.

I am trying to modify a java buffer. I want to put an if condition that checks if the player has (for example) item 1234(a permanent item, not a consumable) in inventory.

And if he has that item, he can add in the scheme buffs with option "canUse = 1" and buffs with option "canUse = 0".

 

Can anyone please help me or try to explain how can I put the condition that checks if the player has the item?

Thank you very much. 

	private String viewAllSchemeBuffs(String scheme, String page, String action)
	{
		List<String> buffList = new ArrayList<>();
		String HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><br>";
		String[] eventSplit = viewAllSchemeBuffs$getBuffCount(scheme).split(" ");
		int TOTAL_BUFF = Integer.parseInt(eventSplit[0]);
		int BUFF_COUNT = Integer.parseInt(eventSplit[1]);
		int DANCE_SONG = Integer.parseInt(eventSplit[2]);
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			if (action.equals("add"))
			{
				HTML_MESSAGE += "You can add <font color=LEVEL>" + (MAX_SCHEME_BUFFS - BUFF_COUNT) + "</font> Buffs and <font color=LEVEL>" + (MAX_SCHEME_DANCES - DANCE_SONG) + "</font> Dances more!";
				String QUERY = "SELECT * FROM npcbuffer_buff_list WHERE buffType IN (" + generateQuery(BUFF_COUNT, DANCE_SONG) + ") AND canUse=1 ORDER BY Buff_Class ASC, id";
				PreparedStatement getBuffCount = con.prepareStatement(QUERY);
				ResultSet rss = getBuffCount.executeQuery();
				while (rss.next())
				{
					String name = SkillTable.getInstance().getInfo(rss.getInt("buffId"), rss.getInt("buffLevel")).getName();
					name = name.replace(" ", "+");
					buffList.add(name + "_" + rss.getInt("buffId") + "_" + rss.getInt("buffLevel"));
				}
			}
			else if (action.equals("remove"))
			{
				HTML_MESSAGE += "You have <font color=LEVEL>" + BUFF_COUNT + "</font> Buffs and <font color=LEVEL>" + DANCE_SONG + "</font> Dances";
				String QUERY = "SELECT * FROM npcbuffer_scheme_contents WHERE scheme_id=? ORDER BY Buff_Class ASC, id";
				PreparedStatement getBuffCount = con.prepareStatement(QUERY);
				getBuffCount.setString(1, scheme);
				ResultSet rss = getBuffCount.executeQuery();
				while (rss.next())
				{
					String name = SkillTable.getInstance().getInfo(rss.getInt("skill_id"), rss.getInt("skill_level")).getName();
					name = name.replace(" ", "+");
					buffList.add(name + "_" + rss.getInt("skill_id") + "_" + rss.getInt("skill_level"));
				}
			}
			else if (DEBUG)
			{
				throw new RuntimeException();
			}
		}
		catch (SQLException e)
		{
			print(e);
		}
		
		HTML_MESSAGE += "<BR1><table border=0><tr>";
		final int buffsPerPage = 16;
		final String width, pageName;
		int pc = ((buffList.size() - 1) / buffsPerPage) + 1;
		if (pc > 5)
		{
			width = "25";
			pageName = "P";
		}
		else
		{
			width = "50";
			pageName = "Page ";
		}
		for (int ii = 1; ii <= pc; ++ii)
		{
			if (ii == Integer.parseInt(page))
			{
				HTML_MESSAGE += "<td width=" + width + " align=center><font color=LEVEL>" + pageName + ii + "</font></td>";
			}
			else if (action.equals("add"))
			{
				HTML_MESSAGE += "<td width=" + width + ">" + "<button value=\"" + pageName + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_1 " + scheme + " " + ii + " x\" width=" + width + " height=20   back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>";
			}
			else if (action.equals("remove"))
			{
				HTML_MESSAGE += "<td width=" + width + ">" + "<button value=\"" + pageName + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_2 " + scheme + " " + ii + " x\" width=" + width + " height=20   back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>";
			}
			else if (DEBUG)
			{
				throw new RuntimeException();
			}
		}
		HTML_MESSAGE += "</tr></table>";
		
		int limit = buffsPerPage * Integer.parseInt(page);
		int start = limit - buffsPerPage;
		int end = Math.min(limit, buffList.size());
		int k = 0;
		for (int i = start; i < end; ++i)
		{
			String value = buffList.get(i);
			value = value.replace("_", " ");
			String[] extr = value.split(" ");
			String name = extr[0];
			name = name.replace("+", " ");
			int id = Integer.parseInt(extr[1]);
			int level = Integer.parseInt(extr[2]);
			/*--String page = extr[3];--*/
			if (action.equals("add"))
			{
				if (!isUsed(scheme, id, level))
				{
					if ((k % 2) != 0)
					{
						HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
					}
					else
					{
						HTML_MESSAGE += "<BR1><table border=0 bgcolor=000000>";
					}
					HTML_MESSAGE += "<tr><td width=35>" + getSkillIconHtml(id, level) + "</td><td fixwidth=170>" + name + "</td><td><button value=\"Add\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " add_buff " + scheme + "_" + id + "_" + level + " " + page + " " + TOTAL_BUFF + "\" width=75 height=21   back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>" + "</tr></table>";
					k += 1;
				}
			}
			else if (action.equals("remove"))
			{
				if ((k % 2) != 0)
				{
					HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
				}
				else
				{
					HTML_MESSAGE += "<BR1><table border=0 bgcolor=000000>";
				}
				HTML_MESSAGE += "<tr><td width=35>" + getSkillIconHtml(id, level) + "</td><td fixwidth=170>" + name + "</td><td><button value=\"Remove\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " remove_buff " + scheme + "_" + id + "_" + level + " " + page + " " + TOTAL_BUFF + "\" width=75 height=21   back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>" + "</table>";
				k += 1;
			}
		}
		HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_select " + scheme + " x x\" width=75 height=21   back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">" + "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=75 height=21   back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
		return HTML_MESSAGE;
	}
Edited by orphangirl

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

So find that bypass responsible for your "scheme" button and do the same. You can also add a check inside the method, like

            if (action.equals("add"))
            {
                if (player.getInventory().getItemsByItemId(57) == null)
                     return;

                HTML_MESSAGE += "You can add <font color=LEVEL>" + (MAX_SCHEME_BUFFS - BUFF_COUNT) + "</font> Buffs and <font color=LEVEL>" + (MAX_SCHEME_DANCES - DANCE_SONG) + "</font> Dances more!";
                String QUERY = "SELECT * FROM npcbuffer_buff_list WHERE buffType IN (" + generateQuery(BUFF_COUNT, DANCE_SONG) + ") AND canUse=1 ORDER BY Buff_Class ASC, id";
                PreparedStatement getBuffCount = con.prepareStatement(QUERY);
                ResultSet rss = getBuffCount.executeQuery();
                while (rss.next())
                {
                    String name = SkillTable.getInstance().getInfo(rss.getInt("buffId"), rss.getInt("buffLevel")).getName();
                    name = name.replace(" ", "+");
                    buffList.add(name + "_" + rss.getInt("buffId") + "_" + rss.getInt("buffLevel"));
                }
            }
)

Else, you can hardcode it in another way, like if player dont have the item, send him normal.htm (with 2 category buffs). If player has the item then send him premium.htm (with 4 category buffs). You got the main point, now just add the checks @ correct places :P

Edited by SweeTs
  • 0
Posted (edited)

Well, it's better to block them when they speak to the npc. For example, when you speak to the npc and press "buffs" to open the buffer or w/e, the bypass looks like this

        else if (currentCommand.startsWith("buffs"))
        {
            showGiveBuffsWindow(player, st.nextToken());
        }

Where showGiveBuffsWindow is like your viewAllSchemeBuffs, so if you want to block players who dont have X item, you can do it like that

        else if (currentCommand.startsWith("buffs"))
        {
            if (player.getInventory().getItemsByItemId(57) == null)
                player.sendMessage("Haaa, you can not use my services.");
            else
                showGiveBuffsWindow(player, st.nextToken());
        }

or vice versa

        else if (currentCommand.startsWith("buffs"))
        {
            if (player.getInventory().getItemsByItemId(57) != null)
                showGiveBuffsWindow(player, st.nextToken());
            else
                player.sendMessage("Haaa, you can not use my services.");
        }
Edited by SweeTs
  • 0
Posted

Thank you for reply!

I understand you, but I already made a change when you talk to the npc.

If a character without that item click on the buffer, he will see 2 categories.

If a character with that item click on the buffer, he will see 4 categories.

Both characters can see scheme section.

But now, if the character WITHOUT item click add buffs on scheme, he can add buffs from the other 2 categories(from that 4 catergories with item).

That's why I try to edit that section.

  • 0
Posted (edited)

When I add this in my code:

 

player.getInventory().getItemsByItemId(here I insert my item id) == null

 

I get this error:

 

player cannot be resolved.

 

 

Example:

if (action.equals("add"))
			{
			.......	THIS IS JUST FOR EXAMPLE
                                if (player.getInventory.getItemsByItemId(hereIinsertitemid) == null)
                                ...........
                                HTML_MESSAGE += "You can add <font color=LEVEL>" + (MAX_SCHEME_BUFFS - BUFF_COUNT) + "</font> Buffs and <font color=LEVEL>" + (MAX_SCHEME_DANCES - DANCE_SONG) + "</font> Dances more!";
				String QUERY = "SELECT * FROM npcbuffer_buff_list WHERE buffType IN (" + generateQuery(BUFF_COUNT, DANCE_SONG) + ") AND canUse=1 ORDER BY Buff_Class ASC, id";
				PreparedStatement getBuffCount = con.prepareStatement(QUERY);
				ResultSet rss = getBuffCount.executeQuery();
				while (rss.next())
				{
					String name = SkillTable.getInstance().getInfo(rss.getInt("buffId"), rss.getInt("buffLevel")).getName();
					name = name.replace(" ", "+");
					buffList.add(name + "_" + rss.getInt("buffId") + "_" + rss.getInt("buffLevel"));
				}
Edited by orphangirl

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

    • "I recently purchased the account panel from this developer and wanted to leave a positive review.   The transaction was smooth, and the developer demonstrated exceptional professionalism throughout the process.   What truly sets them apart is their outstanding post-sale support. They are responsive, patient, and genuinely helpful when addressing questions or issues. It's clear they care about their customers' experience beyond just the initial sale.   I am thoroughly satisfied and grateful for the service. This is a trustworthy seller who provides real value through both a quality product and reliable support. 100% recommended."
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • ⚙️ General Changed “No Carrier” title to “Disconnected” to avoid confusion after abnormal DC. On-screen Clan War kill notifications will no longer appear during Sieges, Epics, or Events. Bladedancer or SwordSinger classes can now log in even when Max Clients (2) is reached, you cannot have both at the same time. The max is 3 clients. Duels will now be aborted if a monster aggros players during a duel (retail-like behavior). Players can no longer send party requests to blocked players (retail-like). Fixed Researcher Euclie NPC dialogue HTML error. Changed Clan leave/kick penalty from 12 hours to 3 hours. 🧙 Skills Adjusted Decrease Atk. Spd. & Decrease Speed land rates in Varka & FoG. Fixed augmented weapons not getting cooldown when entering Olympiad. 🎉 Events New Team vs Team map added. New Save the King map added (old TvT map). Mounts disabled during Events. Letter Collector Event enabled Monsters drop letters until Feb. 13th Louie the Cat in Giran until Feb. 16th Inventory slots +10 during event period 📜 Quests Fixed “Possessor of a Precious Soul Part 1” rare stuck issue when exceeding max quest items. Fixed Seven Signs applying Strife buff/debuff every Monday until restart. 🏆 Milestones New milestone: “Defeat 700 Monsters in Varka” 🎁 Rewards: 200 Varka’s Mane + Daily Coin 🌍 NEW EXP Bonus Zones Hot Springs added Varka Silenos added (hidden spots excluded) As always, thank you for your support! L2Elixir keeps evolving, improving, and growing every day 💙   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs
    • https://sms.pro/ — we are an SMS activation platform  seeking partners  mobile number providers  mobile number owners  owners of GSM modems  SIM card owners We process 1,000,000 activations every day.  寻找合作伙伴  手机号码提供商  手机号码持有者  GSM调制解调器持有者  SIM卡持有者 我们每天处理1,000,000次激活。  Ищем партнеров  Владельцы сим карт  провайдеров  владельцев мобильных номеров  владельцев модемов  Обрабатываем от 1 000 000 активаций в день ⚡️ Fast. Reliable.   https://sms.pro/ Support: https://t.me/alismsorg_bot
  • 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..