Jump to content

Hero (+Clan) Manager


Recommended Posts

Hello there,

i was so boring this Saturday and i started to make this hero manager. So, i am here to share it today. It is being created exclusively by me (`Heroin). It is just a simple NPC, where a player is able to make hero him self...However, he can choose to make all of his online clan members hero. NPC is calculating automatically prizes (depends number of online clan members) and replaces it on NPC html(dialog).

 

Here are some screens of my NPC:

 

http://i47.tinypic.com/161korn.jpg (html dialog preview).

http://i49.tinypic.com/2r3jdaw.jpg ("Make me hero" button).

http://img844.imageshack.us/img844/2430/shot00009v.png ("Make all over my online clan members hero" button).

 

 

How to Install:

 

1. Create a new java file on data/scripts/custom/HeroManager/HeroManager.java

 

Paste this code:

package custom.HeroManager;
import java.util.logging.Logger;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2ClanMember;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.util.Broadcast;

/**
* @author `Heroin
* Made For Maxcheaters.com
*/
public class HeroManager extends Quest
{
private Logger _log = Logger.getLogger(HeroManager.class.getName());
private static final int npcid = 36650; // npc id
private static final int ItemConsumeId = 57; // Item Consume id
private static final int ItemConsumeAmount = 100; // Item Consume Amount
private static String htm = "data/scripts/custom/HeroManager/1.htm"; //html location
private static boolean announce = true; //Announce which players are getting hero from npc or not.
private static String ItemName = ItemTable.getInstance().createDummyItem(ItemConsumeId).getItemName();

public HeroManager(int questId, String name, String descr)
{
	super(questId, name, descr);
	addFirstTalkId(npcid);
	addTalkId(npcid);
	addStartNpc(npcid);
}

@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
	if (event.startsWith("hero"))
	{
		Hero(event, npc, player, event);
	}
	if (event.startsWith("heroall"))
	{
		HeroAll(event, npc, player, event);
	}
	return "";
}

private void Hero(String event, L2Npc npc, L2PcInstance player, String command)
{
	try
	{
		if (player.isHero())
		{
			player.sendMessage("You are already hero!");
			return;
		}
		if (!player.isNoble())
		{
			player.sendMessage("You have to be a noblesser in order to be hero!");
			return;
		}
		else if (player.getInventory().getItemByItemId(ItemConsumeId).getCount() >= ItemConsumeAmount)
		{
			player.destroyItemByItemId("Hero Manager", ItemConsumeId, ItemConsumeAmount, player, true);
			player.sendMessage("Congratulations, you are now a temporary hero!");
			player.setHero(true);
			player.broadcastUserInfo();
			_log.info(player.getName()+" is now a temporary hero.");
			if (announce == true)
			{
				Broadcast.announceToOnlinePlayers(player.getName()+" has been hero from Hero Manager!");
			}
		}
		else if (player.getInventory().getItemByItemId(ItemConsumeId).getCount() < ItemConsumeAmount)
		{
			player.sendMessage("You don't have enough items!");
			return;
		}
		else
		{
			player.sendMessage("Something went wrong.");
			return;
		}
	}
	catch (Exception e)
	{
		player.sendMessage("Something went wrong try again.");
	}
}

@SuppressWarnings("unused")
private void HeroAll(String event, L2Npc npc, L2PcInstance player, String command)
{
	try
	{
		L2Clan clan = player.getClan();
		L2ClanMember[] mem = clan.getMembers();
		int count = clan.getOnlineMembersCount();
		if (clan == null)
		{
			player.sendMessage("You are not in a clan!");
			return;
		}
		if (player.getInventory().getItemByItemId(ItemConsumeId).getCount() < count * mem.length)
		{
			player.sendMessage("You need "+count * mem.length+" "+ItemName+" to make all your online clan members hero!");
			return;
		}
		else if (player.getInventory().getItemByItemId(ItemConsumeId).getCount() >= count * mem.length)
		{
			int c = 0;
			for (L2ClanMember member : mem)
			{
				int id = member.getObjectId();
				L2PcInstance playeru = L2World.getInstance().getPlayer(id);
				playeru.setHero(true);
				playeru.sendMessage(player.getName() + " paid to make you hero.");
				c = c+1;
				playeru.broadcastUserInfo();
			}
			player.destroyItemByItemId("Hero Manager", ItemConsumeId, ItemConsumeAmount*mem.length, player, true);
			player.sendMessage("Congratulations, all your online clan members are now hero!");
			player.setHero(true);
			player.broadcastUserInfo();
			if (announce == true)
			{
				Broadcast.announceToOnlinePlayers("All "+clan.getName()+" members are now hero!");
			}
		}
	}
	catch (Exception e)
	{
		player.sendMessage("Something went wrong try again.");
	}
}

@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
	final int npcId = npc.getNpcId();
	if (player.getQuestState(getName()) == null)
	{
		newQuestState(player);
	}
	int members = player.getClan().getOnlineMembersCount();
	if (npcId == npcid)
	{
		String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htm);
		html = html.replaceAll("%player%", player.getName());
		html = html.replaceAll("%itemname%", ItemName);
		html = html.replaceAll("%solosize%", ""+ItemConsumeAmount+"");
		html = html.replaceAll("%clansize%", ""+members*ItemConsumeAmount+"");

		NpcHtmlMessage npcHtml = new NpcHtmlMessage(0);
		npcHtml.setHtml(html);
		player.sendPacket(npcHtml);
	}
	return "";
}

public static void main(final String[] args)
{
	new HeroManager(-1, HeroManager.class.getSimpleName(), "custom");
	System.out.println("Hero Manager By `Heroin Has been Loaded Successfully!");
}
}

 

2.Create a new htm file on data/scripts/custom/HeroManager/1.htm

Paste this code on it.

 

<html>
<title>%player%</title>
<body><center>
<img src="L2UI_CH3.herotower_deco" width=256 height=32></center><br>
Hello there, i could make you hero easily. Only thing i need is some <font color=LEVEL>%itemname%</font>
and tell me exactly what you want from me.<br>
In order to make <font color=FF0000>only yourself hero,</font> you need: <font color=LEVEL>%solosize% %itemname%</font><br>
In order to make <font color=FF0000>all over your online clan members hero,</font> you need:
<font color=LEVEL>%clansize% %itemname%</font><br><br>


<a action="bypass -h Quest HeroManager hero">Make Me Hero.</a><br>
<a action="bypass -h Quest HeroManager heroall">Make All Over My Online Clan Members Hero.</a><br>


<br><br><br><br><br><br>
<center>
<img src="L2UI_CH3.herotower_deco" width=256 height=32></center>
</body></html>

 

3.Add script on scripts.cfg file:

custom/HeroManager/HeroManager.java

 

How to Modify:

 

Check Variables on code:

private Logger _log = Logger.getLogger(HeroManager.class.getName());
private static final int npcid = 36650; // npc id
private static final int ItemConsumeId = 57; // Item Consume id
private static final int ItemConsumeAmount = 100; // Item Consume Amount
private static String htm = "data/scripts/custom/HeroManager/1.htm"; //html location
private static boolean announce = true; //Announce which players are getting hero from npc or not.
private static String ItemName = ItemTable.getInstance().createDummyItem(ItemConsumeId).getItemName();

 

 

Credits:  `Heroin

Idea:  `Heroin

Link to comment
Share on other sites

read the new rulles kiddo, no double karma on same post

 

kid is your father okay? chek here next time idiot http://maxcheaters.com/forum/index.php?topic=269053.msg2505070#msg2505070 why double  karma here?

 

if u dont know dont talk so much trash.

Link to comment
Share on other sites

kid is your father okay? chek here next time idiot http://maxcheaters.com/forum/index.php?topic=269053.msg2505070#msg2505070 why double  karma here?

 

if u dont know dont talk so much trash.

 

calm trashtalker, they will loose it soon as soon a gmod notices it, about you now, you give 2nd karma? why? Its such a GREAT share to deserve 2 Karma with: More restricted Karma rules?

 

He already got 1 karma for his try but the code has nothing special to deserve more.

Link to comment
Share on other sites

calm trashtalker, they will loose it soon as soon a gmod notices it, about you now, you give 2nd karma? why? Its such a GREAT share to deserve 2 Karma with: More restricted Karma rules?

 

He already got 1 karma for his try but the code has nothing special to deserve more.

 

dude stop trashtalking. i didnt see the new rules so next time tell it firist after flame

Link to comment
Share on other sites

Read new rules

We give +1 ONLY for a good share and only once. If someone else already gave +1 for this share dont give second.

 

Nice share btw keep going ;)

Karma fixed

Link to comment
Share on other sites

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
Reply to this topic...

×   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...