Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.l2jserver.gameserver.model.actor.instance;
- import javolution.text.TextBuilder;
- import com.l2jserver.gameserver.ThreadPoolManager;
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- /**
- * @author Marwan
- * @version 1.0
- */
- public class L2VoteInstance extends L2NpcInstance
- {
- public static int giran = 0, aden = 0, gludio = 0;
- public L2VoteInstance (int objectId, L2NpcTemplate template)
- {
- super(objectId, template);
- ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new vote(), 60000, 150000);
- }
- public class vote implements Runnable
- {
- L2PcInstance p;
- public void vote(L2PcInstance i)
- {
- p = i;
- }
- @Override
- public void run()
- {
- voteWindow();
- }
- }
- @Override
- public void onBypassFeedback(L2PcInstance activeChar, String command)
- {
- if (command.startsWith("giran"))
- {
- activeChar.teleToLocation(82854, 148506, -3472);
- }
- else if (command.startsWith("aden"))
- {
- activeChar.teleToLocation(147450, 27064, -2208);
- }
- else if (command.startsWith("gludio"))
- {
- activeChar.teleToLocation(-14225, 123540, -3121);
- }
- else if (command.startsWith("vgiran"))
- {
- giran += 1;
- }
- else if (command.startsWith("vaden"))
- {
- aden += 1;
- }
- else if (command.startsWith("vgludio"))
- {
- gludio += 1;
- }
- }
- @Override
- public void showChatWindow(L2PcInstance player, int val)
- {
- player.getClient().getConnection().getInetAddress().getHostAddress();
- Events e = new Events();
- TextBuilder tb = new TextBuilder();
- tb.append("<html><title>GK</title><body><br>");
- if ((giran > aden) && (giran > gludio))
- {
- tb.append("<center><button value=\"Giran\" action=\"bypass -h npc_" + this.getObjectId() + "_giran\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- }
- else if ((aden > giran) && (aden > gludio))
- {
- tb.append("<center><button value=\"Aden\" action=\"bypass -h npc_" + this.getObjectId() + "_aden\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- }
- else if ((gludio > giran) && (gludio > aden))
- {
- tb.append("<center><button value=\"Gludio\" action=\"bypass -h npc_" + this.getObjectId() + "_gludio\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- }
- else if ((gludio == 0) && (giran == 0) && (aden == 0))
- {
- tb.append("<center>Voting...</center>");
- }
- tb.append("</body></html>");
- NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- msg.setHtml(tb.toString());
- player.sendPacket(msg);
- }
- public void voteWindow()
- {
- TextBuilder tb = new TextBuilder();
- giran = 0;
- aden = 0;
- gludio = 0;
- tb.append("<html><title>Vote</title><body><br>");
- tb.append("Vote for which map you want :");
- tb.append("<center><button value=\"Giran\" action=\"bypass -h npc_" + this.getObjectId() + "_vgiran\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- tb.append("<center><button value=\"Aden\" action=\"bypass -h npc_" + this.getObjectId() + "_vaden\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- tb.append("<center><button value=\"Gludio\" action=\"bypass -h npc_" + this.getObjectId() + "_vgludio\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- tb.append("</body></html>");
- NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- msg.setHtml(tb.toString());
- for (L2PcInstance i : L2World.getInstance().getAllPlayersArray())
- {
- i.sendPacket(msg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment