Advertisement
Guest User

reward panel

a guest
May 9th, 2013
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.70 KB | None | 0 0
  1. Add code ReqeuestBypassToServer
  2.  
  3.        
  4.     String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
  5.    
  6.  else if (_command.startsWith("hero1"))
  7.             {
  8.                 if(activeChar.isInOlympiadMode())
  9.                 {
  10.                     activeChar.sendMessage("This Menu Cannot Be Used On Olympiad Games.");
  11.                 }
  12.  
  13.                 if(activeChar.isHero())
  14.                 {
  15.                     activeChar.sendMessage("You Are Already A Hero!.");
  16.                 }
  17.                 else if (activeChar.getInventory().getInventoryItemCount(9595, 0) >= 25)
  18.                 {  
  19.                      activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
  20.                      activeChar.setHero(true);
  21.                      updateDatabase(activeChar, Config.HERO_CUSTOM_DAY * 24L * 60L * 60L * 1000L);
  22.                      activeChar.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
  23.                      activeChar.broadcastUserInfo();
  24.                      activeChar.destroyItem("Consume", activeChar.getObjectId(), 1, null, false);
  25.                      activeChar.getInventory().addItem("Wings", 6842, 1, activeChar, null);
  26.                       if (!activeChar.destroyItemByItemId("Vote Reward Item", 9595, 25, activeChar, false))
  27.                         return;
  28.                 }
  29.                 else
  30.                 {
  31.                     activeChar.sendMessage("You Dont Have Vote Reward Item.");
  32.                 }
  33.                
  34.             }
  35.             else if (_command.startsWith("nobless"))
  36.             {
  37.                 if(activeChar.isInOlympiadMode())
  38.                 {
  39.                     activeChar.sendMessage("This Menu Cannot Be Used On Olympiad Games.");
  40.                 }
  41.                
  42.                 if(activeChar.isNoble())
  43.                 {
  44.                     activeChar.sendMessage("You Are Already A Noblesse!.");
  45.                 }
  46.                 else if (activeChar.getInventory().getInventoryItemCount(9595, 0) >= 25)
  47.                 {  
  48.                     activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
  49.                     activeChar.setNoble(true);
  50.                     activeChar.sendMessage("You Are Now a Noble,You Are Granted With Noblesse Status , And Noblesse Skills.");
  51.                     activeChar.broadcastUserInfo();
  52.                     activeChar.destroyItem("Consume", activeChar.getObjectId(), 1, null, false);
  53.                     activeChar.getInventory().addItem("Tiara", 7694, 1, activeChar, null);
  54.                       if (!activeChar.destroyItemByItemId("Vote Reward Item", 9595, 25, activeChar, false))
  55.                         return;
  56.                 }
  57.                 else
  58.                 {
  59.                     activeChar.sendMessage("You Dont Have Vote Reward Item.");
  60.                 }
  61.             }
  62.     private void updateDatabase(L2PcInstance player, long heroTime)
  63.     {
  64.         Connection con = null;
  65.         try
  66.         {
  67.             if(player == null)
  68.                 return;
  69.  
  70.             con = L2DatabaseFactory.getInstance().getConnection(false);
  71.             PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
  72.  
  73.             stmt.setInt(1, player.getObjectId());
  74.             stmt.setString(2, player.getName());
  75.             stmt.setInt(3, 1);
  76.             stmt.setInt(4, player.isNoble() ? 1 : 0);
  77.             stmt.setInt(5, player.isDonator() ? 1 : 0);
  78.             stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
  79.             stmt.execute();
  80.             stmt.close();
  81.             stmt = null;
  82.         }
  83.         catch(Exception e)
  84.         {
  85.             if(Config.ENABLE_ALL_EXCEPTIONS)
  86.                 e.printStackTrace();
  87.            
  88.             _log.log(Level.SEVERE, "Error: could not update database: ", e);
  89.         }
  90.         finally
  91.         {
  92.             CloseUtil.close(con);
  93.            
  94.             con = null;
  95.         }
  96.     }
  97.  
  98. go com.l2jfrozen.gameserver.handler.VoicedCommandHandler
  99. Paste Here code
  100.  
  101. registerVoicedCommandHandler(new votereward());
  102.  
  103. add Code VoicedCommandHandler
  104. Name votereward
  105.  
  106. /*
  107.  * This program is free software: you can redistribute it and/or modify it under
  108.  * the terms of the GNU General Public License as published by the Free Software
  109.  * Foundation, either version 3 of the License, or (at your option) any later
  110.  * version.
  111.  *
  112.  * This program is distributed in the hope that it will be useful, but WITHOUT
  113.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  114.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  115.  * details.
  116.  *
  117.  * You should have received a copy of the GNU General Public License along with
  118.  * this program. If not, see <http://www.gnu.org/licenses/>.
  119.  */
  120. package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
  121.  
  122. import javolution.text.TextBuilder;
  123.  
  124. import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
  125. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  126. import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  127.  
  128. public class votereward implements IVoicedCommandHandler
  129. {
  130.     private static String[] _voicedCommands =
  131.     {
  132.         "reward"
  133.     };
  134.    
  135.  
  136.     @Override
  137.     public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  138.     {
  139.         if (command.equalsIgnoreCase("reward"))
  140.         {
  141.             if (activeChar.getInventory().getInventoryItemCount(9595, 0) >= 1)
  142.             {    
  143.               votepanel(activeChar);
  144.             }
  145.             else
  146.             {
  147.                 activeChar.sendMessage("You Dont Have Vote Reward Items.");
  148.                 activeChar.sendMessage("Try again.");
  149.             }
  150.         }
  151.         return true;
  152.     }
  153.    
  154.     public static void votepanel(L2PcInstance activeChar)
  155.     {
  156.         NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  157.         TextBuilder replyMSG = new TextBuilder("<html><center><body><title>Reward Panel</title><br>");
  158.         replyMSG.append("<center><font color=\"FFFF00\">"+ activeChar.getName() +"</font></center><br>");
  159.         replyMSG.append("<center><font color=3c3c3c>__________________________________</font></center><br>");
  160.         replyMSG.append("<table>");
  161.         replyMSG.append("<tr>");
  162.         replyMSG.append("<td><img src=\"icon.etc_alphabet_r_i00\" width=32 height=32 align=\"center\"></td>");
  163.         replyMSG.append("<td><img src=\"icon.etc_alphabet_e_i00\" width=32 height=32 align=\"center\"></td>");
  164.         replyMSG.append("<td><img src=\"icon.etc_alphabet_w_i00\" width=32 height=32 align=\"center\"></td>");
  165.         replyMSG.append("<td><img src=\"icon.etc_alphabet_a_i00\" width=32 height=32 align=\"center\"></td>");
  166.         replyMSG.append("<td><img src=\"icon.etc_alphabet_r_i00\" width=32 height=32 align=\"center\"></td>");
  167.         replyMSG.append("<td><img src=\"icon.etc_alphabet_d_i00\" width=32 height=32 align=\"center\"></td>");
  168.         replyMSG.append("</tr>");
  169.         replyMSG.append("</table>");
  170.         replyMSG.append("<br>");
  171.         replyMSG.append("<table>");
  172.         replyMSG.append("<tr>");
  173.         replyMSG.append("<td><img src=\"icon.etc_alphabet_p_i00\" width=32 height=32 align=\"center\"></td>");
  174.         replyMSG.append("<td><img src=\"icon.etc_alphabet_a_i00\" width=32 height=32 align=\"center\"></td>");
  175.         replyMSG.append("<td><img src=\"icon.etc_alphabet_n_i00\" width=32 height=32 align=\"center\"></td>");
  176.         replyMSG.append("<td><img src=\"icon.etc_alphabet_e_i00\" width=32 height=32 align=\"center\"></td>");
  177.         replyMSG.append("<td><img src=\"icon.etc_alphabet_l_i00\" width=32 height=32 align=\"center\"></td>");
  178.         replyMSG.append("</tr>");
  179.         replyMSG.append("</table><br>");
  180.         replyMSG.append("<center><font color=3c3c3c>__________________________________</font></center><br>");
  181.         if(activeChar.isHero())
  182.         {  
  183.             replyMSG.append("<center><font color=\"00FF00\">Hero Status:</font> Enabled</center><br>");
  184.         }
  185.         else
  186.         {
  187.             replyMSG.append("<button value=\"Hero 1 Day (25 Vote Item)\" action=\"bypass -h hero1\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\">");
  188.         }
  189.         if(activeChar.isNoble())
  190.         {  
  191.             replyMSG.append("<center><font color=\"00FF00\">Noble Status:</font> Enabled</center><br>");
  192.         }
  193.         else
  194.         {
  195.             replyMSG.append("<button value=\"Noblesse (25 Vote Item)\" action=\"bypass -h nobless\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\">");
  196.         }
  197.         replyMSG.append("<center><font color=3c3c3c>__________________________________</font></center><br>");
  198.         replyMSG.append("</body></html>");
  199.  
  200.         adminReply.setHtml(replyMSG.toString());
  201.         activeChar.sendPacket(adminReply);
  202.  
  203.         adminReply = null;
  204.         replyMSG = null;
  205.     }
  206.  
  207.     @Override
  208.     public String[] getVoicedCommandList()
  209.     {
  210.         return _voicedCommands;
  211.     }
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement