Advertisement
Elfocrash

Elfocrash's Survey System

Sep 27th, 2012
1,414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 40.10 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P l2jelfo
  3. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 26)
  6. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  7. @@ -22,6 +22,7 @@
  8.  import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
  9.  import net.sf.l2j.gameserver.handler.AdminCommandHandler;
  10.  import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  11. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSurvey;
  12.  import net.sf.l2j.gameserver.handler.usercommandhandlers.Menu;
  13.  import net.sf.l2j.gameserver.model.L2Object;
  14.  import net.sf.l2j.gameserver.model.L2World;
  15. @@ -96,6 +97,86 @@
  16.             {
  17.                 playerHelp(activeChar, _command.substring(12));
  18.             }
  19. +           else if (_command.equals("survey_vote1"))
  20. +           {
  21. +               if(AdminSurvey.running == false)
  22. +               {
  23. +                   activeChar.sendMessage("There is no survey running now");
  24. +                   return;
  25. +               }
  26. +              
  27. +               if(activeChar.hasVotedSurvey())
  28. +               {
  29. +                   activeChar.sendMessage("You already voted for that survey.");
  30. +                   return;
  31. +               }
  32. +              
  33. +               AdminSurvey.ans1_vote_count++;
  34. +               activeChar.sendMessage("You voted : " + AdminSurvey.ans1 + ". Thanks for voting");
  35. +           }
  36. +          
  37. +           else if (_command.equals("survey_vote2"))
  38. +           {
  39. +               if(AdminSurvey.running == false)
  40. +               {
  41. +                   activeChar.sendMessage("There is no survey running now");
  42. +                   return;
  43. +               }
  44. +               if(activeChar.hasVotedSurvey())
  45. +               {
  46. +                   activeChar.sendMessage("You already voted for that survey.");
  47. +                   return;
  48. +               }
  49. +              
  50. +               AdminSurvey.ans2_vote_count++;
  51. +               activeChar.sendMessage("You voted : " + AdminSurvey.ans2 + ". Thanks for voting");
  52. +           }
  53. +           else if (_command.equals("survey_vote3"))
  54. +           {
  55. +               if(AdminSurvey.running == false)
  56. +               {
  57. +                   activeChar.sendMessage("There is no survey running now");
  58. +                   return;
  59. +               }
  60. +               if(activeChar.hasVotedSurvey())
  61. +               {
  62. +                   activeChar.sendMessage("You already voted for that survey.");
  63. +                   return;
  64. +               }
  65. +               AdminSurvey.ans3_vote_count++;
  66. +               activeChar.sendMessage("You voted : " + AdminSurvey.ans3 + ". Thanks for voting");
  67. +           }
  68. +           else if (_command.equals("survey_vote4"))
  69. +           {  
  70. +               if(AdminSurvey.running == false)
  71. +               {
  72. +                   activeChar.sendMessage("There is no survey running now");
  73. +                   return;
  74. +               }
  75. +               if(activeChar.hasVotedSurvey())
  76. +               {
  77. +                   activeChar.sendMessage("You already voted for that survey.");
  78. +                   return;
  79. +               }
  80. +               AdminSurvey.ans4_vote_count++;
  81. +               activeChar.sendMessage("You voted : " + AdminSurvey.ans4 + ". Thanks for voting");
  82. +           }
  83. +          
  84. +           else if (_command.equals("survey_vote5"))
  85. +           {  
  86. +               if(AdminSurvey.running == false)
  87. +               {
  88. +                   activeChar.sendMessage("There is no survey running now");
  89. +                   return;
  90. +               }
  91. +               if(activeChar.hasVotedSurvey())
  92. +               {
  93. +                   activeChar.sendMessage("You already voted for that survey.");
  94. +                   return;
  95. +               }
  96. +               AdminSurvey.ans5_vote_count++;
  97. +               activeChar.sendMessage("You voted : " + AdminSurvey.ans5 + ". Thanks for voting");
  98. +           }
  99.             else if (_command.startsWith("npc_"))
  100.             {
  101.                 if (!activeChar.validateBypass(_command))
  102. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  103. ===================================================================
  104. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 26)
  105. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  106. @@ -66,6 +66,7 @@
  107.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSiege;
  108.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSkill;
  109.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSpawn;
  110. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSurvey;
  111.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTarget;
  112.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
  113.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminUnblockIp;
  114. @@ -135,6 +136,7 @@
  115.         registerAdminCommandHandler(new AdminUnblockIp());
  116.         registerAdminCommandHandler(new AdminZone());
  117.         registerAdminCommandHandler(new AdminGoHide());
  118. +       registerAdminCommandHandler(new AdminSurvey());
  119.     }
  120.    
  121.     public void registerAdminCommandHandler(IAdminCommandHandler handler)
  122. Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  123. ===================================================================
  124. --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java    (revision 26)
  125. +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java    (working copy)
  126. @@ -25,6 +25,7 @@
  127.  import net.sf.l2j.Config;
  128.  import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Heal;
  129.  import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Online;
  130. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Survey;
  131.  
  132.  public class VoicedCommandHandler
  133.  {
  134. @@ -45,6 +46,9 @@
  135.     {
  136.         _datatable = new FastMap<>();
  137.        
  138. +       registerVoicedCommandHandler(new Survey());
  139. +      
  140. +      
  141.         if (Config.ALLOW_ONLINE_COMMAND)
  142.         {
  143.             registerVoicedCommandHandler(new Online());
  144. Index: java/net/sf/l2j/gameserver/GameServer.java
  145. ===================================================================
  146. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 26)
  147. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  148. @@ -231,7 +231,7 @@
  149.         OlympiadGameManager.getInstance();
  150.         Olympiad.getInstance();
  151.         Hero.getInstance();
  152. -       Hide.getInstance();
  153. +       //Hide.getInstance();
  154.        
  155.         Util.printSection("Four Sepulchers");
  156.         FourSepulchersManager.getInstance().init();
  157. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java
  158. ===================================================================
  159. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java    (revision 0)
  160. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java    (working copy)
  161. @@ -0,0 +1,739 @@
  162. +/*
  163. + * This program is free software: you can redistribute it and/or modify it under
  164. + * the terms of the GNU General Public License as published by the Free Software
  165. + * Foundation, either version 3 of the License, or (at your option) any later
  166. + * version.
  167. + *
  168. + * This program is distributed in the hope that it will be useful, but WITHOUT
  169. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  170. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  171. + * details.
  172. + *
  173. + * You should have received a copy of the GNU General Public License along with
  174. + * this program. If not, see <http://www.gnu.org/licenses/>.
  175. + */
  176. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  177. +
  178. +import java.util.Collection;
  179. +import java.util.StringTokenizer;
  180. +
  181. +import javolution.text.TextBuilder;
  182. +
  183. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  184. +import net.sf.l2j.gameserver.model.L2World;
  185. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  186. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  187. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  188. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  189. +import net.sf.l2j.gameserver.util.Broadcast;
  190. +
  191. +/**
  192. + *
  193. + * @author Elfocrash
  194. + *
  195. + */
  196. +public class AdminSurvey implements IAdminCommandHandler
  197. +{
  198. +   public static int options = 2;
  199. +   public static int mode = 0;
  200. +   public static boolean running = false;
  201. +   private static boolean qset = false;
  202. +   private static boolean ans1set = false;
  203. +   private static boolean ans2set = false;
  204. +   private static boolean ans3set = false;
  205. +   private static boolean ans4set = false;
  206. +   private static boolean ans5set = false;
  207. +   public static String quest = "";
  208. +   public static String ans1 = "";
  209. +   public static String ans2 = "";
  210. +   public static String ans3 = "";
  211. +   public static String ans4 = "";
  212. +   public static String ans5 = "";
  213. +   public static int ans1_vote_count = 0;
  214. +   public static int ans2_vote_count = 0;
  215. +   public static int ans3_vote_count = 0;
  216. +   public static int ans4_vote_count = 0;
  217. +   public static int ans5_vote_count = 0;
  218. +  
  219. +   private static final String[] ADMIN_COMMANDS =
  220. +   {
  221. +       "admin_survey_start" , "admin_survey_results" , "admin_opmore" , "admin_opless" , "admin_survey_run1","admin_survey_run2","admin_survey_run3","admin_survey_run4", "admin_survey_qset",
  222. +       "admin_survey_ans1set", "admin_survey_ans2set","admin_survey_ans3set","admin_survey_ans4set","admin_survey_ans5set", "admin_survey_end" ,"admin_survey_results"
  223. +   };
  224. +    
  225. +   @Override
  226. +   public boolean useAdminCommand(String command, L2PcInstance activeChar)
  227. +   {
  228. +       if (command.equals("admin_survey_start"))
  229. +           startHtml(activeChar);
  230. +      
  231. +       if (command.equals("admin_survey_results"))
  232. +           resultsHtml(activeChar);
  233. +      
  234. +      
  235. +       if (command.equals("admin_survey_end"))
  236. +       {
  237. +           running = false;
  238. +           resultsHtml(activeChar);
  239. +           quest = "";
  240. +           ans1 = "";
  241. +           ans2 = "";
  242. +           ans3 = "";
  243. +           ans4 = "";
  244. +           ans5 = "";
  245. +           mode = 0;
  246. +           ans1_vote_count = 0;
  247. +           ans2_vote_count = 0;
  248. +           ans3_vote_count = 0;
  249. +           ans4_vote_count = 0;
  250. +           ans5_vote_count = 0;
  251. +           setQset(false);
  252. +           setAns1set(false);
  253. +           setAns2set(false);
  254. +           setAns3set(false);
  255. +           setAns4set(false);
  256. +           setAns5set(false);
  257. +          
  258. +           Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
  259. +           for (L2PcInstance onlinePlayers : pls)
  260. +           {
  261. +               onlinePlayers.setHasVotedSurvey(false);
  262. +           }
  263. +              
  264. +          
  265. +           Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The survey session is over.Thanks everyone for voting."));
  266. +          
  267. +       }
  268. +      
  269. +       if(command.equals("admin_opmore"))
  270. +           if(options <= 4)
  271. +           {
  272. +               options++;
  273. +               startHtml(activeChar);
  274. +           }
  275. +           else
  276. +           {
  277. +               return false;
  278. +           }
  279. +      
  280. +       if(command.equals("admin_opless"))
  281. +           if(options >= 3)
  282. +           {
  283. +               options--;
  284. +               startHtml(activeChar);
  285. +           }
  286. +           else
  287. +           {
  288. +               return false;
  289. +           }
  290. +      
  291. +       if(command.startsWith("admin_survey_qset"))
  292. +       {
  293. +           if(isQset())
  294. +           {
  295. +               quest = "";
  296. +               setQset(false);
  297. +               startHtml(activeChar);
  298. +           }
  299. +           else if(!isQset())
  300. +           {
  301. +           StringTokenizer s = new StringTokenizer(command);
  302. +           s.nextToken();
  303. +          
  304. +           try{
  305. +              
  306. +               while(s.hasMoreTokens())
  307. +               quest = quest + s.nextToken() + " ";
  308. +               setQset(true);
  309. +               startHtml(activeChar);
  310. +          
  311. +           }
  312. +           catch(Exception e)
  313. +           {
  314. +               e.printStackTrace();
  315. +           }
  316. +       }
  317. +       }
  318. +      
  319. +       if(command.startsWith("admin_survey_ans1set"))
  320. +       {
  321. +           if(isAns1set())
  322. +           {
  323. +               ans1 = "";
  324. +               setAns1set(false);
  325. +               startHtml(activeChar);
  326. +           }
  327. +           else if(!isAns1set())
  328. +           {
  329. +           StringTokenizer s = new StringTokenizer(command);
  330. +           s.nextToken();
  331. +          
  332. +           try{
  333. +              
  334. +               while(s.hasMoreTokens())
  335. +               ans1 = ans1 + s.nextToken() + " ";
  336. +               setAns1set(true);
  337. +               startHtml(activeChar);
  338. +          
  339. +           }
  340. +           catch(Exception e)
  341. +           {
  342. +               e.printStackTrace();
  343. +           }
  344. +       }
  345. +       }
  346. +      
  347. +       if(command.startsWith("admin_survey_ans2set"))
  348. +       {
  349. +           if(isAns2set())
  350. +           {
  351. +               ans2 = "";
  352. +               setAns2set(false);
  353. +               startHtml(activeChar);
  354. +           }
  355. +           else if(!isAns2set())
  356. +           {
  357. +           StringTokenizer s = new StringTokenizer(command);
  358. +           s.nextToken();
  359. +          
  360. +           try{
  361. +              
  362. +               while(s.hasMoreTokens())
  363. +               ans2 = ans2 + s.nextToken() + " ";
  364. +               setAns2set(true);
  365. +               startHtml(activeChar);
  366. +          
  367. +           }
  368. +           catch(Exception e)
  369. +           {
  370. +               e.printStackTrace();
  371. +           }
  372. +       }
  373. +       }
  374. +      
  375. +       if(command.startsWith("admin_survey_ans3set"))
  376. +       {
  377. +           if(isAns3set())
  378. +           {
  379. +               ans3 = "";
  380. +               setAns3set(false);
  381. +               startHtml(activeChar);
  382. +           }
  383. +           else if(!isAns3set())
  384. +           {
  385. +           StringTokenizer s = new StringTokenizer(command);
  386. +           s.nextToken();
  387. +          
  388. +           try{
  389. +              
  390. +               while(s.hasMoreTokens())
  391. +               ans3 = ans3 + s.nextToken() + " ";
  392. +               setAns3set(true);
  393. +               startHtml(activeChar);
  394. +          
  395. +           }
  396. +           catch(Exception e)
  397. +           {
  398. +               e.printStackTrace();
  399. +           }
  400. +       }
  401. +       }
  402. +       if(command.startsWith("admin_survey_ans4set"))
  403. +       {
  404. +           if(isAns4set())
  405. +           {
  406. +               ans4 = "";
  407. +               setAns4set(false);
  408. +               startHtml(activeChar);
  409. +           }
  410. +           else if(!isAns4set())
  411. +           {
  412. +           StringTokenizer s = new StringTokenizer(command);
  413. +           s.nextToken();
  414. +          
  415. +           try{
  416. +              
  417. +               while(s.hasMoreTokens())
  418. +               ans4 = ans4 + s.nextToken() + " ";
  419. +               setAns4set(true);
  420. +               startHtml(activeChar);
  421. +          
  422. +           }
  423. +           catch(Exception e)
  424. +           {
  425. +               e.printStackTrace();
  426. +           }
  427. +       }
  428. +       }
  429. +      
  430. +       if(command.startsWith("admin_survey_ans5set"))
  431. +       {
  432. +           if(isAns5set())
  433. +           {
  434. +               ans5 = "";
  435. +               setAns5set(false);
  436. +               startHtml(activeChar);
  437. +           }
  438. +           else if(!isAns5set())
  439. +           {
  440. +           StringTokenizer s = new StringTokenizer(command);
  441. +           s.nextToken();
  442. +          
  443. +           try{
  444. +              
  445. +               while(s.hasMoreTokens())
  446. +               ans5 = ans5 + s.nextToken() + " ";
  447. +               setAns5set(true);
  448. +               startHtml(activeChar);
  449. +          
  450. +           }
  451. +           catch(Exception e)
  452. +           {
  453. +               e.printStackTrace();
  454. +           }
  455. +       }
  456. +       }
  457. +      
  458. +      
  459. +      
  460. +       if(command.startsWith("admin_survey_run1"))
  461. +       {
  462. +           if(running == true)
  463. +           {
  464. +               activeChar.sendMessage("A survey is already in progres.");
  465. +               return false;
  466. +           }
  467. +           if(!isQset() || !isAns1set() || !isAns2set())
  468. +           {
  469. +               activeChar.sendMessage("You have to set all the fields before you start the survey");
  470. +               return false;
  471. +           }
  472. +               mode = 1;
  473. +               running = true;
  474. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","Admin started a new survey with main question "+ quest+". Use .survey to vote."));
  475. +          
  476. +          
  477. +       }
  478. +      
  479. +       if(command.startsWith("admin_survey_run2"))
  480. +       {
  481. +           if(running == true)
  482. +           {
  483. +               activeChar.sendMessage("A survey is already in progress");
  484. +               return false;
  485. +          
  486. +           }
  487. +           if(!isQset() || !isAns1set() || !isAns2set() || !isAns3set())
  488. +           {
  489. +               activeChar.sendMessage("You have to set all the fields before you start the survey");
  490. +               return false;
  491. +           }
  492. +               mode = 2;
  493. +               running = true;
  494. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","Admin started a new survey with main question "+ quest+". Use .survey to vote."));
  495. +          
  496. +          
  497. +       }
  498. +      
  499. +       if(command.startsWith("admin_survey_run3"))
  500. +       {
  501. +           if(running == true)
  502. +           {
  503. +               activeChar.sendMessage("A survey is already in progress");
  504. +               return false;
  505. +          
  506. +           }
  507. +          
  508. +           if(!isQset() || !isAns1set() || !isAns2set() || !isAns3set() || !isAns4set())
  509. +           {
  510. +               activeChar.sendMessage("You have to set all the fields before you start the survey");
  511. +               return false;
  512. +           }
  513. +               mode = 3;
  514. +               running = true;
  515. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","Admin started a new survey with main question "+ quest+". Use .survey to vote."));
  516. +          
  517. +          
  518. +       }
  519. +      
  520. +       if(command.startsWith("admin_survey_run4"))
  521. +       {
  522. +           if(running == true)
  523. +           {
  524. +               activeChar.sendMessage("A survey is already in progress");
  525. +               return false;
  526. +          
  527. +           }
  528. +          
  529. +           if(!isQset() || !isAns1set() || !isAns2set() || !isAns3set() || !isAns4set() || !isAns5set())
  530. +           {
  531. +               activeChar.sendMessage("You have to set all the fields before you start the survey");
  532. +               return false;
  533. +           }
  534. +               mode = 4;
  535. +               running = true;
  536. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","Admin started a new survey with main question "+ quest+". Use .survey to vote."));
  537. +          
  538. +          
  539. +       }
  540. +      
  541. +           return true;
  542. +   }
  543. +  
  544. +   @Override
  545. +   public String[] getAdminCommandList()
  546. +   {
  547. +       return ADMIN_COMMANDS;
  548. +   }
  549. +  
  550. +   private static void startHtml(L2PcInstance activeChar)
  551. +   {
  552. +       NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  553. +       TextBuilder tb = new TextBuilder("");
  554. +      
  555. +       tb.append("<html><head><title>Start Survey form</title></head><body>");
  556. +       tb.append("<center>");
  557. +       tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
  558. +       tb.append("<tr>");
  559. +       tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
  560. +       tb.append("<td valign=\"top\"><font color=\"FF6600\">Start a Survey</font>");  
  561. +       tb.append("<br1><font color=\"FF6600\">"+activeChar.getName()+"</font>, use this form in order to start a survey.<br1></td>");
  562. +       tb.append("</tr>");
  563. +       tb.append("</table>");
  564. +       tb.append("</center>");
  565. +       tb.append("<center>");
  566. +       if(!isQset())
  567. +       {
  568. +           tb.append("<font color=\"FF6600\">Type in the main question of the survey.</font><br>");
  569. +           tb.append("<table border=\"0\" width=\"250\" height=\"16\" bgcolor=\"000000\">");
  570. +           tb.append("<tr><td><multiedit var=\"quest\" width=170 height=20></td><td><a action=\"bypass -h admin_survey_qset $quest\">Save</a></td></tr></table>");
  571. +       }
  572. +       if(isQset())
  573. +       {
  574. +           tb.append("<font color=\"FF6600\">The question set is:<br>");
  575. +           tb.append("<table border=\"0\" width=\"250\" height=\"16\" bgcolor=\"000000\">");
  576. +           tb.append("<tr><td><font color=\"FF0000\">" + quest+"</font></td><td><a action=\"bypass -h admin_survey_qset\">Edit</a></td></tr></table>");
  577. +       }
  578. +       tb.append("<br><font color=\"FF6600\">Possible answers.");
  579. +       tb.append("<table border=\"0\" width=\"70\" height=\"16\" bgcolor=\"000000\">");
  580. +       tb.append("<tr>");
  581. +       tb.append("<td width=\"52\">More</td>");
  582. +       tb.append("<td width=\"16\"><button action=\"bypass -h admin_opmore\" width=16 height=16 back=\"L2UI_CH3.upbutton_down\" fore=\"L2UI_CH3.upbutton\"></td>");
  583. +       tb.append("</tr>");
  584. +       tb.append("<tr>");
  585. +       tb.append("<td width=\"52\">Less</td>");
  586. +       tb.append("<td width=\"16\"><button action=\"bypass -h admin_opless\" width=16 height=16 back=\"L2UI_CH3.downbutton_down\" fore=\"L2UI_CH3.downbutton_down\"></td>");
  587. +       tb.append("</tr>");
  588. +       tb.append("</table>");
  589. +       tb.append("<table width=\"300\" height=\"20\">");
  590. +       tb.append("<tr>");
  591. +       tb.append("<td align=\"center\" width=\"40\">Answer 1:</td>");
  592. +       if(!isAns1set())
  593. +       {
  594. +           tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans1\" width=150 height=16></td>");
  595. +           tb.append("<td><a action=\"bypass -h admin_survey_ans1set $ans1\">Save</a></td>");
  596. +       }
  597. +       else if(isAns1set())
  598. +       {
  599. +           tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans1 + "</font></td>");
  600. +           tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans1set\">Edit</a></td>");
  601. +       }
  602. +       tb.append("</tr>");
  603. +       tb.append("<tr>");
  604. +       tb.append("<td align=\"center\" width=\"40\">Answer 2:</td>");
  605. +       if(!isAns2set())
  606. +       {
  607. +           tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans2\" width=150 height=16></td>");
  608. +           tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans2set $ans2\">Save</a></td>");
  609. +       }
  610. +       else if(isAns2set())
  611. +       {
  612. +           tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans2 + "</font></td>");
  613. +           tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans2set\">Edit</a></td>");
  614. +       }
  615. +       tb.append("</tr>");
  616. +       if(options == 3)
  617. +       {
  618. +           tb.append("<tr>");
  619. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  620. +           if(!isAns3set())
  621. +           {
  622. +               tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans3\" width=150 height=16></td>");
  623. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set $ans3\">Save</a></td>");
  624. +           }
  625. +           else if(isAns3set())
  626. +           {
  627. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans3 + "</font></td>");
  628. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set\">Edit</a></td>");
  629. +           }
  630. +           tb.append("</tr>");
  631. +       }
  632. +       if(options == 4)
  633. +       {
  634. +           tb.append("<tr>");
  635. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  636. +           if(!isAns3set())
  637. +           {
  638. +               tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans3\" width=150 height=16></td>");
  639. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set $ans3\">Save</a></td>");
  640. +           }
  641. +           else if(isAns3set())
  642. +           {
  643. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans3 + "</font></td>");
  644. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set\">Edit</a></td>");
  645. +           }
  646. +           tb.append("</tr>");
  647. +           tb.append("<tr>");
  648. +           tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
  649. +           if(!isAns4set())
  650. +           {
  651. +               tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans4\" width=150 height=16></td>");
  652. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set $ans4\">Save</a></td>");
  653. +           }
  654. +           else if(isAns4set())
  655. +           {
  656. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans4 + "</font></td>");
  657. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set\">Edit</a></td>");
  658. +           }
  659. +           tb.append("</tr>");
  660. +       }
  661. +       if(options == 5)
  662. +       {
  663. +           tb.append("<tr>");
  664. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  665. +           if(!isAns3set())
  666. +           {
  667. +               tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans3\" width=150 height=16></td>");
  668. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set $ans3\">Save</a></td>");
  669. +           }
  670. +           else if(isAns3set())
  671. +           {
  672. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans3 + "</font></td>");
  673. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set\">Edit</a></td>");
  674. +           }
  675. +           tb.append("</tr>");
  676. +           tb.append("<tr>");
  677. +           tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
  678. +           if(!isAns4set())
  679. +           {
  680. +               tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans4\" width=150 height=16></td>");
  681. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set $ans4\">Save</a></td>");
  682. +           }
  683. +           else if(isAns4set())
  684. +           {
  685. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans4 + "</font></td>");
  686. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set\">Edit</a></td>");
  687. +           }
  688. +           tb.append("</tr>");
  689. +           tb.append("<tr>");
  690. +           tb.append("<td align=\"center\" width=\"40\">Answer 5:</td>");
  691. +           if(!isAns5set())
  692. +           {
  693. +               tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans5\" width=150 height=16></td>");
  694. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans5set $ans5\">Save</a></td>");
  695. +           }
  696. +           else if(isAns5set())
  697. +           {
  698. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans5 + "</font></td>");
  699. +               tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans5set\">Edit</a></td>");
  700. +           }
  701. +           tb.append("</tr>");
  702. +       }
  703. +       tb.append("</table><br>");
  704. +       if(options == 2)
  705. +       tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run1\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
  706. +       if(options == 3)
  707. +       tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run2\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
  708. +       if(options == 4)
  709. +       tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run3\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
  710. +       if(options == 5)
  711. +       tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run4\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
  712. +       tb.append("</center>");
  713. +       tb.append("</body></html>");
  714. +      
  715. +       nhm.setHtml(tb.toString());
  716. +       activeChar.sendPacket(nhm);
  717. +   }
  718. +  
  719. +   private static void resultsHtml(L2PcInstance activeChar)
  720. +   {
  721. +       NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  722. +       TextBuilder tb = new TextBuilder("");
  723. +      
  724. +       tb.append("<html><head><title>Survey form</title></head><body>");
  725. +       tb.append("<center>");
  726. +       tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
  727. +       tb.append("<tr>");
  728. +       tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
  729. +       tb.append("<td valign=\"top\"><font color=\"FF6600\">Survey</font>");  
  730. +       tb.append("<br1><font color=\"FF6600\">"+activeChar.getName()+"</font>, here are the survey's results.<br1></td>");
  731. +       tb.append("</tr>");
  732. +       tb.append("</table>");
  733. +       tb.append("</center>");
  734. +       tb.append("<center>");
  735. +       tb.append("<font color=\"FF6600\">The question set is:<br>");
  736. +       tb.append("<font color=\"FF0000\">" + AdminSurvey.quest+"</font></center>");
  737. +       tb.append("<br><font color=\"FF6600\">Choose an answer.");
  738. +       tb.append("<table width=\"300\" height=\"20\">");
  739. +       tb.append("<tr>");
  740. +       tb.append("<td align=\"center\" width=\"40\">Answer 1:</td>");
  741. +       tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans1 + "</font></td>");
  742. +       tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans1_vote_count+ "</font></td>");
  743. +       tb.append("</tr>");
  744. +       tb.append("<tr>");
  745. +       tb.append("<td align=\"center\" width=\"40\">Answer 2:</td>");
  746. +       tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans2 + "</font></td>");
  747. +       tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans2_vote_count+ "</font></td>");
  748. +       tb.append("</tr>");
  749. +       if(mode == 2)
  750. +       {
  751. +           tb.append("<tr>");
  752. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  753. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
  754. +               tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans3_vote_count+ "</font></td>");
  755. +          
  756. +           tb.append("</tr>");
  757. +       }
  758. +       if(mode == 3)
  759. +       {
  760. +           tb.append("<tr>");
  761. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  762. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
  763. +               tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans3_vote_count+ "</font></td>");
  764. +          
  765. +           tb.append("</tr>");
  766. +           tb.append("<tr>");
  767. +           tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
  768. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
  769. +               tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans4_vote_count+ "</font></td>");
  770. +          
  771. +           tb.append("</tr>");
  772. +       }
  773. +       if(mode == 4)
  774. +       {
  775. +           tb.append("<tr>");
  776. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  777. +
  778. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
  779. +               tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans3_vote_count+ "</font></td>");
  780. +
  781. +           tb.append("</tr>");
  782. +           tb.append("<tr>");
  783. +           tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
  784. +
  785. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
  786. +               tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans4_vote_count+ "</font></td>");
  787. +          
  788. +           tb.append("</tr>");
  789. +           tb.append("<tr>");
  790. +           tb.append("<td align=\"center\" width=\"40\">Answer 5:</td>");
  791. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans5 + "</font></td>");
  792. +               tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans5_vote_count+ "</font></td>");
  793. +          
  794. +           tb.append("</tr>");
  795. +       }
  796. +       tb.append("</table><br>");
  797. +       if(running == true)
  798. +       tb.append("<center><button value=\"End the survey\" action=\"bypass -h admin_survey_end\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\"></center>");
  799. +       tb.append("</body></html>");
  800. +      
  801. +       nhm.setHtml(tb.toString());
  802. +       activeChar.sendPacket(nhm);
  803. +   }
  804. +
  805. +   /**
  806. +    * @return the qset
  807. +    */
  808. +   public static boolean isQset()
  809. +   {
  810. +       return qset;
  811. +   }
  812. +
  813. +   /**
  814. +    * @param qset the qset to set
  815. +    */
  816. +   public static void setQset(boolean qset)
  817. +   {
  818. +       AdminSurvey.qset = qset;
  819. +   }
  820. +
  821. +   /**
  822. +    * @return the ans1set
  823. +    */
  824. +   public static boolean isAns1set()
  825. +   {
  826. +       return ans1set;
  827. +   }
  828. +
  829. +   /**
  830. +    * @param ans1set the ans1set to set
  831. +    */
  832. +   public static void setAns1set(boolean ans1set)
  833. +   {
  834. +       AdminSurvey.ans1set = ans1set;
  835. +   }
  836. +
  837. +   /**
  838. +    * @return the ans2set
  839. +    */
  840. +   public static boolean isAns2set()
  841. +   {
  842. +       return ans2set;
  843. +   }
  844. +
  845. +   /**
  846. +    * @param ans2set the ans2set to set
  847. +    */
  848. +   public static void setAns2set(boolean ans2set)
  849. +   {
  850. +       AdminSurvey.ans2set = ans2set;
  851. +   }
  852. +
  853. +   /**
  854. +    * @return the ans3set
  855. +    */
  856. +   public static boolean isAns3set()
  857. +   {
  858. +       return ans3set;
  859. +   }
  860. +
  861. +   /**
  862. +    * @param ans3set the ans3set to set
  863. +    */
  864. +   public static void setAns3set(boolean ans3set)
  865. +   {
  866. +       AdminSurvey.ans3set = ans3set;
  867. +   }
  868. +
  869. +   /**
  870. +    * @return the ans4set
  871. +    */
  872. +   public static boolean isAns4set()
  873. +   {
  874. +       return ans4set;
  875. +   }
  876. +
  877. +   /**
  878. +    * @param ans4set the ans4set to set
  879. +    */
  880. +   public static void setAns4set(boolean ans4set)
  881. +   {
  882. +       AdminSurvey.ans4set = ans4set;
  883. +   }
  884. +
  885. +   /**
  886. +    * @return the ans5set
  887. +    */
  888. +   public static boolean isAns5set()
  889. +   {
  890. +       return ans5set;
  891. +   }
  892. +
  893. +   /**
  894. +    * @param ans5set the ans5set to set
  895. +    */
  896. +   public static void setAns5set(boolean ans5set)
  897. +   {
  898. +       AdminSurvey.ans5set = ans5set;
  899. +   }
  900. +}
  901. \ No newline at end of file
  902. Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Survey.java
  903. ===================================================================
  904. --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Survey.java    (revision 0)
  905. +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Survey.java    (working copy)
  906. @@ -0,0 +1,155 @@
  907. +/* This program is free software; you can redistribute it and/or modify
  908. + * it under the terms of the GNU General Public License as published by
  909. + * the Free Software Foundation; either version 2, or (at your option)
  910. + * any later version.
  911. + *
  912. + * This program is distributed in the hope that it will be useful,
  913. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  914. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  915. + * GNU General Public License for more details.
  916. + *
  917. + * You should have received a copy of the GNU General Public License
  918. + * along with this program; if not, write to the Free Software
  919. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  920. + * 02111-1307, USA.
  921. + *
  922. + * http://www.gnu.org/copyleft/gpl.html
  923. + */
  924. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  925. +
  926. +import javolution.text.TextBuilder;
  927. +
  928. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  929. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSurvey;
  930. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  931. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  932. +
  933. +/**
  934. + *
  935. + * @author  Elfocrash
  936. + *
  937. + */
  938. +public class Survey implements IVoicedCommandHandler
  939. +{
  940. +   private static final String[] VOICED_COMMANDS = { "survey" };
  941. +  
  942. +   @Override
  943. +   public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  944. +   {
  945. +       if (command.equals("survey"))
  946. +       {
  947. +           if(AdminSurvey.running == false)
  948. +           {
  949. +               activeChar.sendMessage("There is no survey running now");
  950. +               return false;
  951. +           }
  952. +          
  953. +           if(activeChar.hasVotedSurvey())
  954. +           {
  955. +               activeChar.sendMessage("You already voted for that survey.");
  956. +               return false;
  957. +           }
  958. +          
  959. +           if(AdminSurvey.running == true)
  960. +               mainHtml(activeChar);
  961. +       }
  962. +      
  963. +      
  964. +      
  965. +       return true;
  966. +   }
  967. +  
  968. +   private static void mainHtml(L2PcInstance activeChar)
  969. +   {
  970. +       NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  971. +       TextBuilder tb = new TextBuilder("");
  972. +      
  973. +       tb.append("<html><head><title>Survey form</title></head><body>");
  974. +       tb.append("<center>");
  975. +       tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
  976. +       tb.append("<tr>");
  977. +       tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
  978. +       tb.append("<td valign=\"top\"><font color=\"FF6600\">Survey</font>");  
  979. +       tb.append("<br1><font color=\"FF6600\">"+activeChar.getName()+"</font>, use this form in order to give us feedback.<br1></td>");
  980. +       tb.append("</tr>");
  981. +       tb.append("</table>");
  982. +       tb.append("</center>");
  983. +       tb.append("<center>");
  984. +
  985. +           tb.append("<font color=\"FF6600\">The question set is:<br>");
  986. +           tb.append("<font color=\"FF0000\">" + AdminSurvey.quest+"</font>");
  987. +       tb.append("<br><font color=\"FF6600\">Choose an answer.");
  988. +       tb.append("<table width=\"300\" height=\"20\">");
  989. +       tb.append("<tr>");
  990. +       tb.append("<td align=\"center\" width=\"40\">Answer 1:</td>");
  991. +           tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans1 + "</font></td>");
  992. +           tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote1\">Vote</a></td>");
  993. +  
  994. +       tb.append("</tr>");
  995. +       tb.append("<tr>");
  996. +       tb.append("<td align=\"center\" width=\"40\">Answer 2:</td>");
  997. +           tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans2 + "</font></td>");
  998. +           tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote2\">Vote</a></td>");
  999. +      
  1000. +       tb.append("</tr>");
  1001. +       if(AdminSurvey.mode == 2)
  1002. +       {
  1003. +           tb.append("<tr>");
  1004. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  1005. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
  1006. +               tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote3\">Vote</a></td>");
  1007. +          
  1008. +           tb.append("</tr>");
  1009. +       }
  1010. +       if(AdminSurvey.mode == 3)
  1011. +       {
  1012. +           tb.append("<tr>");
  1013. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  1014. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
  1015. +               tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote3\">Vote</a></td>");
  1016. +          
  1017. +           tb.append("</tr>");
  1018. +           tb.append("<tr>");
  1019. +           tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
  1020. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
  1021. +               tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote4\">Vote</a></td>");
  1022. +          
  1023. +           tb.append("</tr>");
  1024. +       }
  1025. +       if(AdminSurvey.mode == 4)
  1026. +       {
  1027. +           tb.append("<tr>");
  1028. +           tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
  1029. +
  1030. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
  1031. +               tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote3\">Vote</a></td>");
  1032. +
  1033. +           tb.append("</tr>");
  1034. +           tb.append("<tr>");
  1035. +           tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
  1036. +
  1037. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
  1038. +               tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote4\">Vote</a></td>");
  1039. +          
  1040. +           tb.append("</tr>");
  1041. +           tb.append("<tr>");
  1042. +           tb.append("<td align=\"center\" width=\"40\">Answer 5:</td>");
  1043. +               tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans5 + "</font></td>");
  1044. +               tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote5\">Vote</a></td>");
  1045. +          
  1046. +           tb.append("</tr>");
  1047. +       }
  1048. +       tb.append("</table><br>");
  1049. +       tb.append("</center>");
  1050. +       tb.append("</body></html>");
  1051. +      
  1052. +       nhm.setHtml(tb.toString());
  1053. +       activeChar.sendPacket(nhm);
  1054. +   }
  1055. +  
  1056. +   @Override
  1057. +   public String[] getVoicedCommandList()
  1058. +   {
  1059. +       return VOICED_COMMANDS;
  1060. +   }
  1061. +}
  1062. \ No newline at end of file
  1063. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  1064. ===================================================================
  1065. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 26)
  1066. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  1067. @@ -365,6 +365,7 @@
  1068.     private String _accountName;
  1069.     private long _deleteTimer;
  1070.    
  1071. +   private boolean _hasVotedSurvey = false;
  1072.     private boolean _isOnline = false;
  1073.     private long _onlineTime;
  1074.     private long _onlineBeginTime;
  1075. @@ -11662,4 +11663,20 @@
  1076.             }
  1077.         }
  1078.     }
  1079. +
  1080. +   /**
  1081. +    * @return the _hasVotedSurvey
  1082. +    */
  1083. +   public boolean hasVotedSurvey()
  1084. +   {
  1085. +       return _hasVotedSurvey;
  1086. +   }
  1087. +
  1088. +   /**
  1089. +    * @param _hasVotedSurvey the _hasVotedSurvey to set
  1090. +    */
  1091. +   public void setHasVotedSurvey(boolean _hasVotedSurvey)
  1092. +   {
  1093. +       this._hasVotedSurvey = _hasVotedSurvey;
  1094. +   }
  1095.  }
  1096. \ No newline at end of file
  1097. ### Eclipse Workspace Patch 1.0
  1098. #P l2jelfo
  1099. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  1100. ===================================================================
  1101. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 27)
  1102. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  1103. @@ -112,6 +112,7 @@
  1104.                 }
  1105.                
  1106.                 AdminSurvey.ans1_vote_count++;
  1107. +               activeChar.setHasVotedSurvey(true);
  1108.                 activeChar.sendMessage("You voted : " + AdminSurvey.ans1 + ". Thanks for voting");
  1109.             }
  1110.            
  1111. @@ -129,6 +130,7 @@
  1112.                 }
  1113.                
  1114.                 AdminSurvey.ans2_vote_count++;
  1115. +               activeChar.setHasVotedSurvey(true);
  1116.                 activeChar.sendMessage("You voted : " + AdminSurvey.ans2 + ". Thanks for voting");
  1117.             }
  1118.             else if (_command.equals("survey_vote3"))
  1119. @@ -144,6 +146,7 @@
  1120.                     return;
  1121.                 }
  1122.                 AdminSurvey.ans3_vote_count++;
  1123. +               activeChar.setHasVotedSurvey(true);
  1124.                 activeChar.sendMessage("You voted : " + AdminSurvey.ans3 + ". Thanks for voting");
  1125.             }
  1126.             else if (_command.equals("survey_vote4"))
  1127. @@ -159,6 +162,7 @@
  1128.                     return;
  1129.                 }
  1130.                 AdminSurvey.ans4_vote_count++;
  1131. +               activeChar.setHasVotedSurvey(true);
  1132.                 activeChar.sendMessage("You voted : " + AdminSurvey.ans4 + ". Thanks for voting");
  1133.             }
  1134.            
  1135. @@ -175,6 +179,7 @@
  1136.                     return;
  1137.                 }
  1138.                 AdminSurvey.ans5_vote_count++;
  1139. +               activeChar.setHasVotedSurvey(true);
  1140.                 activeChar.sendMessage("You voted : " + AdminSurvey.ans5 + ". Thanks for voting");
  1141.             }
  1142.             else if (_command.startsWith("npc_"))
  1143. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java
  1144. ===================================================================
  1145. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java    (revision 27)
  1146. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java    (working copy)
  1147. @@ -73,6 +73,23 @@
  1148.        
  1149.         if (command.equals("admin_survey_end"))
  1150.         {
  1151. +           int moreVotes = ans1_vote_count;
  1152. +           if (moreVotes < ans2_vote_count) {moreVotes = ans2_vote_count;}
  1153. +           if (moreVotes < ans3_vote_count) {moreVotes = ans3_vote_count;}
  1154. +           if (moreVotes < ans4_vote_count) {moreVotes = ans4_vote_count;}
  1155. +           if (moreVotes < ans5_vote_count) {moreVotes = ans5_vote_count;}
  1156. +          
  1157. +           Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The survey session is over.Thanks everyone for voting."));
  1158. +           if( moreVotes == ans1_vote_count)
  1159. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The answer "+ ans1 +" won the survey with " + ans1_vote_count +" votes on the question : "+ quest+"."));
  1160. +           if( moreVotes == ans2_vote_count)
  1161. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The answer "+ ans2 +" won the survey with " + ans2_vote_count +" votes on the question : "+ quest+"."));
  1162. +           if( moreVotes == ans3_vote_count)
  1163. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The answer "+ ans3 +" won the survey with " + ans3_vote_count +" votes on the question : "+ quest+"."));
  1164. +           if( moreVotes == ans4_vote_count)
  1165. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The answer "+ ans4 +" won the survey with " + ans4_vote_count +" votes on the question : "+ quest+"."));
  1166. +           if( moreVotes == ans5_vote_count)
  1167. +               Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The answer "+ ans5 +" won the survey with " + ans5_vote_count +" votes on the question : "+ quest+"."));
  1168.             running = false;
  1169.             resultsHtml(activeChar);
  1170.             quest = "";
  1171. @@ -101,8 +118,8 @@
  1172.             }
  1173.                
  1174.            
  1175. -           Broadcast.toAllOnlinePlayers(new CreatureSay(0,Say2.ANNOUNCEMENT,"Survey","The survey session is over.Thanks everyone for voting."));
  1176.            
  1177. +          
  1178.         }
  1179.        
  1180.         if(command.equals("admin_opmore"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement