Jump to content
  • 0

[help] clan reputation manager


Question

Posted

hello i've tried to make a clan rep manager but i have one problem with "case" ..

 

i have added this "private static final int CLITEM = Config.CLITEMID;" in L2ClanTraderInstance and this:

 

case CLITEM:
reputation = Config.CLPOINTS;
itemCount = Config.CLCOUNT;
break;[code]

but i get warning, "case expressions must be constant expressions" how can i fix it ? :-\

6 answers to this question

Recommended Posts

  • 0
Posted

Show your switch statement, not only one case. Also i can't understand why you created a static variable(private static final int CLITEM = Config.CLITEMID;), since it's pointless and it also won't be updated if you //reload configs.

  • 0
Posted

I was just showing how a switch should work. Obviously, if your code is an "if" instead of a swtich, use "if" system.

 

As you don't post L2ClanTraderInstance method where it should be I can't guess (and I'm lazy to open Eclipse just to check).

  • 0
Posted

/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.actor.instance;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowInfoUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;

public final class L2ClanTraderInstance extends L2Npc
{

private static final int CLITEM = Config.CLITEMID;

public L2ClanTraderInstance(int objectId, L2NpcTemplate template)
{
	super(objectId, template);
	setInstanceType(InstanceType.L2ClanTraderInstance);
}

@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
	NpcHtmlMessage html = new NpcHtmlMessage(1);

	if (command.equalsIgnoreCase("crp"))
	{
		if (player.getClan().getLevel() > 4)
			html.setFile(player.getHtmlPrefix(), "data/html/clantrader/" + getNpcId() + "-2.htm");
		else
			html.setFile(player.getHtmlPrefix(), "data/html/clantrader/" + getNpcId() + "-1.htm");

		sendHtmlMessage(player, html);
		return;
	}
	else if (command.startsWith("exchange"))
	{
		int itemId = Integer.parseInt(command.substring(9).trim());

		int reputation = 0;
		int itemCount = 0;

		L2ItemInstance item = player.getInventory().getItemByItemId(itemId);
		long playerItemCount = item == null ? 0 : item.getCount();

		switch (itemId)
		{
			case 9911:
				reputation = Config.BLOODALLIANCE_POINTS;
				itemCount = 1;
				break;
			case 9910:
				reputation = Config.BLOODOATH_POINTS;
				itemCount = 10;
				break;
			case 9912:
				reputation = Config.KNIGHTSEPAULETTE_POINTS;
				itemCount = 100;
				break;
			case CLITEM:
				reputation = Config.CLPOINTS;
				itemCount = Config.CLCOUNT;
				break;
		}


		if (playerItemCount >= itemCount)
		{
			player.destroyItemByItemId("exchange", itemId, itemCount, player, true);

			player.getClan().addReputationScore(reputation, true);
			player.getClan().broadcastToOnlineMembers(new PledgeShowInfoUpdate(player.getClan()));

			SystemMessage sm =  SystemMessage.getSystemMessage(SystemMessageId.CLAN_ADDED_S1S_POINTS_TO_REPUTATION_SCORE);
			sm.addNumber(reputation);
			player.sendPacket(sm);

			html.setFile(player.getHtmlPrefix(), "data/html/clantrader/" + getNpcId() + "-ExchangeSuccess.htm");
		}
		else
			html.setFile(player.getHtmlPrefix(), "data/html/clantrader/" + getNpcId() + "-ExchangeFailed.htm");

		sendHtmlMessage(player, html);
		return;
	}
	else
		super.onBypassFeedback(player, command);
}

private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html)
{
	html.replace("%objectId%", String.valueOf(getObjectId()));
	player.sendPacket(html);
}

@Override
public void showChatWindow(L2PcInstance player)
{
	player.sendPacket(ActionFailed.STATIC_PACKET);
	String filename = "data/html/clantrader/" + getNpcId() + "-no.htm";

	if (player.isClanLeader())
		filename = "data/html/clantrader/" + getNpcId() + ".htm";

	NpcHtmlMessage html = new NpcHtmlMessage(1);
	html.setFile(player.getHtmlPrefix(), filename);
	html.replace("%objectId%", String.valueOf(getObjectId()));
	player.sendPacket(html);
}

@Override
public String getHtmlPath(int npcId, int val)
{
	String pom = "";

	if (val == 0)
		pom = "" + npcId;
	else
		pom = npcId + "-" + val;

	return "data/html/clantrader/" + pom + ".htm";
}
}

 

and another question :-s , i have created a new buff... how can i make it to appear at "Reinforcement skills" not at "Psihycal Skills" ?

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 HARUNA — TRUE INTERLUDE EXPERIENCE 🔥 Real PvP. Real economy. No pay-to-win. Built for players who miss true Lineage 2 Interlude. ⚔️ SERVER RATES 🔥 EXP / SP: x3 💰 Adena: x2 🧬 Spoil: x1 💠 Seal Stones: x1 🏰 Raid Drop: x1 🔥 Raid EXP: x2 🎮 CORE FEATURES ✔️ Max 2 clients per IP ✔️ Retail enchant / augment / skill enchant ✔️ Party EXP bonus up to x2.2 ✔️ 20+4 Buff Slots ✔️ Retail buff durations ✔️ 35 sec spawn protection 🎁 Daily Login Rewards 🎥 Streamer Reward System 🎯 L2 Day Scrolls at start (Mage / Fighter) ➡️ Cannot be traded / sold / dropped 🏰 ENDGAME 🏆 Olympiad starts at 40 Nobles 💀 Cursed weapons disabled until first Heroes 🛡 Raid lure protection ⚖️ Long-term healthy economy 🚫 CLEAN SERVER ❌ No pay-to-win ❌ No broken customs ❌ No admin favoritism ❌ No fake population Only skill, clans, and real PvP. 📅 LAUNCH 🗓 06.02.2026 🌐 Website: www.l2haruna.com 💬 Discord: https://discord.gg/7DDC9Dsxnh
    • do you happen to know which dll loads the files?
    • Big vouch for Splicho. He’s been one of the best guys in the L2 scene for a long time, always helping out and providing what’s needed. Solid dude and easy to work with.   If anyone wants to work with him, make sure you’re serious and don’t waste his time. He really wants to build something good that brings back the real Lineage 2 feeling and gives the community a good vibe. Transparency is important to him and that’s rare these days.   Before hitting him up, be honest with yourself if you actually want to commit. Too many people nowadays come with stupid ideas and end up ruining projects and wasting the time and effort others put in.   I 100% recommend working with this guy.
    • Dragonic 2 – High Five is a fully custom private server, built with an original visual identity and integrated premium systems. We offer a stable, modern, and optimized experience, combining classic High Five gameplay with new features created especially for the community. The server is live and available to all players. You can access the official website here: 👉 https://dragonic2.ddns.net/ If you encounter any bugs or issues, please report them so we can fix them as quickly as possible. Join the adventure and discover Dragonic 2 — High Five.
  • 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