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

    • L2 Kings    Stage 1 – The Awakening Dynasty and Moirai Level Cap: 83 Gear: Dynasty -Moirai & Weapons (Shop for Adena + Drop from mobs/instances ) Masterwork System: Available (Neolithics S required with neolithics u can do armor parts foundation aswell) Class Cloaks: Level 1 - Masterwork sets such us moirai/dynasty stats are boosted also vesper(stage 2) Olf T-Shirt: +6 (fails don’t reset) safe is +2 Dolls: Level 1 Belts: Low & Medium Enchant: Safe +3 / Max +8 / Attribution Easy in Moirai-Dynasty . Main Zones: Varka Outpost: Easy farm, Adena, EXP for new players = > 80- 100kk hour Dragon Valley: Main farm zone — , 100–120kk/hour Weapon Weakness System active (all classes can farm efficiently) Archers get vampiric auto-hits vs mobs Dragon Valley Center: Main Party Zone — boosted drops (Blessed enchants, Neolithics chance) => farm like 150-200kk per hour. Dragon Valley North: Spoil Zone (Asofe + crafting materials for MW) Primeval Isle: Safe autofarm zone (low adena for casual players) ==> 50kk per hour Forge of the Gods & Imperial Tomb: Available from Stage 1 (lower Adena reward in compare with Dragon Valley) Hellbound also avaliable from stage 1 In few words all zones opened but MAIN farm zone with boosted adena and drops is Dragon valley also has more mobs Instances: Zaken (24h Reuse) → Instead of Vespers drop Moirai , 100% chance to drop 1 of 9 dolls lvl 1, Zaken 7-Day Jewelry Raid Bosses (7 RBs): Drop Moirai Parts + Neolithic S grade instead of Vespers parts that has 7 Rb Quest give Icarus Weapons Special Feature 7rb bosses level up soul crystals aswell. Closed Areas : Monaster of SIlence, LOA, ( It wont have mobs) / Mahum Quest/Lizardmen off) Grand Epics: Unlocked on Day 4 of Stage 1 → Antharas, Valakas, Baium, AQ, etc ================================================================================= Stage 2 – Rise of Vespers Level Cap: 85 Gear: Moirai Armors (Adena GM SHOP / Craft/ Drop) Weapons: Icarus Cloaks: Level 2 Olf: +8 Dolls: Level 2 Belts: High & Top Enchant: Safe +3 / Max +8 Masterwork can be with Neolithics S84 aswell but higher so craft will be usefull aswell. 7 Raid Boss Quest Updated: Now works retail give vesper weapons 7rb Bosses Drops : Vespers Instances: Zaken : Drops to retail vespers + the dolls and the extra items that we added on stage 1 New Freya Instance: Added — drops vespers and instead of mid s84 weapons will drop vespers . Extra drops Blessed Bottle of Freya - drops 100% chance 1 of 9 dolls. Farm Areas Dragon Valley remains main farm New Zone : Lair of Antharas (mobs nerfed and added drop Noble stone so solo players can farm too) New Party Zone : LOA Circle   ============================================================================   Stage 3 – The Vorpal ERA Gear: Vorpal Unclock Cloaks: Level 3 Olf: +10 (max cap) Dolls: Level 3 Enchant: Safe +3 / Max +12 Farm Zones : Dragon Valley Center Scorpions becomes a normal solo zone (no longer party zone) Drops:   LOA & Knorik → Mid Weapons avaliable in drop New Party Zone Kariks Instances: Easy Freya Drops Mid Weapons Frintezza Release =================================================================================     Stage 4 – Elegia Era (Final Stage) Elegia Unlock Gear: Elegia Weapons: Elegia TOP s84 ( farmed via H-Freya/ Drops ) Cloaks: Level 5 Dolls: Level 3 (final bonuses) Enchant: Safe +6 / Max +16 Instances: Hard Freya → Drops Elegia Weapons + => The Instance will drop 2-3 parts for sure and also will be able to Join with 7 people . Party Zone will have also drop chances for elegia armor parts and weapons but small   Events (Hourly): Win: 50 Event Medals + 3 GCM + morewards Lose: 25 Medals + 1 GCM + more rewards Tie: 30 Medals + 2 GCM + more rewards   ================================================================================ Epic Fragments Currency Participating in Daily Bosses mass rewarding all players Participating in Instances (zaken freya frintezza etc) all players get reward ================================================================================ Adena - Main server currency (all items in gm shop require adena ) Event Medals (Festival Adena) - Event shop currency Donation coins you can buy with them dressme,cosmetics and premium account Epic Fragments you can buy with them fake epic jewels Olympiad Tokens you can buy many items from olympiad shop (Hero Coin even items that are on next stages) Olympiad Win = 1000 Tokens / Lose = 500 Tokens ================================================================================= Offline Autofarm Allows limited Offline farming requires offline autofarm ticket that you get by voting etc ================================================================================= Grand Epics have Specific Custom NPC that can spawn Epics EU/LATIN TIME ZONE ================================================================================= First Olympiad Day 19 December First Heroes 22 December ( 21 December Last day of 1st Period) After that olympiad will be weekly. ================================================================================= Item price and economy Since adena is main coin of server and NOT donation coins we will always add new items in gm shop with adena in order to burn the adena of server and not be inflation . =================================================================================        
    • Hello, I'd like to change a title color for custom npc.  I created custom NPC, cloned existing. I put unique id for it in npcname-e, npcgrp and database. I have "0" to serverSideName in db, so that it would use npcname-e, but instead it has "NoNameNPC"and no title color change.
    • Trusted Guy 100% ,  I asked him for some work and he did it right away.
  • 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