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" ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...