Guest User

map vote

a guest
Feb 3rd, 2013
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. package com.l2jserver.gameserver.model.actor.instance;
  2.  
  3. import javolution.text.TextBuilder;
  4.  
  5. import com.l2jserver.gameserver.ThreadPoolManager;
  6. import com.l2jserver.gameserver.model.L2World;
  7. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  8. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  9.  
  10. /**
  11. * @author Marwan
  12. * @version 1.0
  13. */
  14. public class L2VoteInstance extends L2NpcInstance
  15. {
  16. public static int giran = 0, aden = 0, gludio = 0;
  17.  
  18. public L2VoteInstance (int objectId, L2NpcTemplate template)
  19. {
  20. super(objectId, template);
  21. ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new vote(), 60000, 150000);
  22. }
  23.  
  24. public class vote implements Runnable
  25. {
  26. L2PcInstance p;
  27.  
  28. public void vote(L2PcInstance i)
  29. {
  30. p = i;
  31. }
  32.  
  33. @Override
  34. public void run()
  35. {
  36. voteWindow();
  37.  
  38. }
  39. }
  40.  
  41. @Override
  42. public void onBypassFeedback(L2PcInstance activeChar, String command)
  43. {
  44. if (command.startsWith("giran"))
  45. {
  46.  
  47. activeChar.teleToLocation(82854, 148506, -3472);
  48.  
  49. }
  50. else if (command.startsWith("aden"))
  51. {
  52.  
  53. activeChar.teleToLocation(147450, 27064, -2208);
  54.  
  55. }
  56. else if (command.startsWith("gludio"))
  57. {
  58.  
  59. activeChar.teleToLocation(-14225, 123540, -3121);
  60.  
  61. }
  62. else if (command.startsWith("vgiran"))
  63. {
  64.  
  65. giran += 1;
  66.  
  67. }
  68. else if (command.startsWith("vaden"))
  69. {
  70.  
  71. aden += 1;
  72. }
  73. else if (command.startsWith("vgludio"))
  74. {
  75.  
  76. gludio += 1;
  77. }
  78. }
  79.  
  80. @Override
  81. public void showChatWindow(L2PcInstance player, int val)
  82. {
  83. player.getClient().getConnection().getInetAddress().getHostAddress();
  84. Events e = new Events();
  85. TextBuilder tb = new TextBuilder();
  86. tb.append("<html><title>GK</title><body><br>");
  87.  
  88. if ((giran > aden) && (giran > gludio))
  89. {
  90. 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>");
  91. }
  92. else if ((aden > giran) && (aden > gludio))
  93. {
  94. 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>");
  95. }
  96. else if ((gludio > giran) && (gludio > aden))
  97. {
  98. 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>");
  99. }
  100. else if ((gludio == 0) && (giran == 0) && (aden == 0))
  101. {
  102. tb.append("<center>Voting...</center>");
  103. }
  104.  
  105. tb.append("</body></html>");
  106. NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  107. msg.setHtml(tb.toString());
  108. player.sendPacket(msg);
  109. }
  110.  
  111. public void voteWindow()
  112. {
  113. TextBuilder tb = new TextBuilder();
  114. giran = 0;
  115. aden = 0;
  116. gludio = 0;
  117. tb.append("<html><title>Vote</title><body><br>");
  118. tb.append("Vote for which map you want :");
  119. 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>");
  120. 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>");
  121. 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>");
  122.  
  123. tb.append("</body></html>");
  124. NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  125. msg.setHtml(tb.toString());
  126. for (L2PcInstance i : L2World.getInstance().getAllPlayersArray())
  127. {
  128. i.sendPacket(msg);
  129. }
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment