Advertisement
vampir

Vampir Legend System!

Mar 24th, 2011
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.91 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_Server
  3. Index: java/com/l2jserver/gameserver/model/olympiad/Olympiad.java
  4. ===================================================================
  5. --- java/com/l2jserver/gameserver/model/olympiad/Olympiad.java  (revision 4526)
  6. +++ java/com/l2jserver/gameserver/model/olympiad/Olympiad.java  (working copy)
  7. @@ -44,6 +44,7 @@
  8.  import com.l2jserver.gameserver.ThreadPoolManager;
  9.  import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
  10.  import com.l2jserver.gameserver.instancemanager.ZoneManager;
  11. +import com.l2jserver.gameserver.model.L2World;
  12.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  13.  import com.l2jserver.gameserver.model.entity.Hero;
  14.  import com.l2jserver.gameserver.network.SystemMessageId;
  15. @@ -477,6 +478,12 @@
  16.         _scheduledCompStart = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() {
  17.             public void run()
  18.             {
  19. +               //running change legend
  20. +               for (L2PcInstance atkChar: L2World.getInstance().getAllPlayers().values()){
  21. +                   atkChar.pvpPeriodToBase(atkChar.getName());
  22. +               }
  23. +               L2PcInstance.changeLegend();
  24. +              
  25.                 if (isOlympiadEnd())
  26.                     return;
  27.                
  28. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  29. ===================================================================
  30. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 4526)
  31. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  32. @@ -287,8 +287,8 @@
  33.    
  34.     // Character Character SQL String Definitions:
  35.     private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createTime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  36. -   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=? WHERE charId=?";
  37. -   private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language FROM characters WHERE charId=?";
  38. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,legend=?,pvp_period=?  WHERE charId=?";
  39. +   private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language,legend,pvp_period FROM characters WHERE charId=?";
  40.    
  41.     // Character Teleport Bookmark:
  42.     private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
  43. @@ -452,6 +452,16 @@
  44.    
  45.     private boolean _isIn7sDungeon = false;
  46.    
  47. +   //Legend System
  48. +   private int _legend;
  49. +  
  50. +   private int _pvpPeriod;
  51. +  
  52. +   public static String legendName;
  53. +  
  54. +   public static int mostPvpPeriod;
  55. +  
  56. +  
  57.     private int _bookmarkslot = 0; // The Teleport Bookmark Slot
  58.    
  59.     private List<TeleportBookmark> tpbookmark = new FastList<TeleportBookmark>();
  60. @@ -982,7 +992,109 @@
  61.             return (getSkill() != null) ? getSkill().getId() : -1;
  62.         }
  63.     }
  64. +   public void pvpPeriodToBase(String x){
  65. +       Connection con = null;
  66. +       try
  67. +       {
  68. +       con = L2DatabaseFactory.getInstance().getConnection();
  69. +       PreparedStatement statement = con.prepareStatement("UPDATE characters SET pvp_period=? where char_name=?");
  70. +       statement.setInt(1, getPvpPeriod());
  71. +       statement.setString(2, x);
  72. +       statement.execute();
  73. +       statement.close();
  74. +       }
  75. +       catch (Exception e)
  76. +       {
  77. +       }
  78. +       finally
  79. +       {
  80. +           L2DatabaseFactory.close(con);
  81. +       }
  82. +   }
  83. +   public static void changeLegend(){
  84. +       Connection con = null;
  85. +       try
  86. +       {
  87. +
  88. +           con = L2DatabaseFactory.getInstance().getConnection();
  89. +          
  90. +           //choosing legend and making him legend in game
  91. +           PreparedStatement statement = con.prepareStatement("SELECT char_name,pvp_period FROM characters WHERE accesslevel=0 ORDER BY pvp_period DESC LIMIT 1");
  92. +           ResultSet rset = statement.executeQuery();
  93. +          
  94. +           if(rset.next())
  95. +           {
  96. +               legendName = rset.getString("char_name");              
  97. +               mostPvpPeriod = rset.getInt("pvp_period");
  98. +               Announcements.getInstance().announceToAll(legendName+" is new server Legend with "+mostPvpPeriod+" kills today" );
  99. +               for (L2PcInstance atkChar: L2World.getInstance().getAllPlayers().values()){
  100. +                   if (atkChar.getName().equals(legendName)){
  101. +                       atkChar.setLegend(1);
  102. +                       atkChar.updateLegend();
  103. +                   }
  104. +               }
  105. +           }
  106. +           rset.close();
  107. +           statement.close();
  108. +          
  109. +           //deleting from DB stats from last day
  110. +           statement = con.prepareStatement("UPDATE characters SET legend=0, pvp_period=0");
  111. +           statement.execute();
  112. +           statement.close();
  113. +          
  114. +           //deleting pvp and legends from game also
  115. +           for (L2PcInstance atkChar: L2World.getInstance().getAllPlayers().values()){
  116. +               if(!atkChar.getName().equals(legendName)){
  117. +                   atkChar.setLegend(0);
  118. +                   atkChar.updateLegend();
  119. +               }
  120. +               atkChar.setPvpPeriod(0);   
  121. +           }
  122. +          
  123. +           //Making some1 else a legend
  124. +           statement = con.prepareStatement("UPDATE characters SET legend=? where char_name=?");
  125. +           statement.setInt(1, 1);
  126. +           statement.setString(2, legendName);
  127. +           statement.execute();
  128. +           statement.close();
  129. +       }
  130. +       catch (Exception e)
  131. +       {
  132. +           _log.warning("Could not Change Legend");
  133. +       }
  134. +       finally
  135. +       {
  136. +           L2DatabaseFactory.close(con);
  137. +       }
  138. +   }
  139.    
  140. +   public void setLegend(int x){
  141. +       _legend = x;
  142. +   }
  143. +   public void updateLegend(){
  144. +       if(getLegend()==1){
  145. +           setTitle("I am Legend");
  146. +           broadcastPacket(new CharInfo(this));
  147. +           broadcastTitleInfo();
  148. +           storeCharBase();
  149. +       }else{
  150. +           setTitle("");
  151. +           broadcastPacket(new CharInfo(this));
  152. +           broadcastTitleInfo();
  153. +           storeCharBase();
  154. +       }
  155. +   }
  156. +   public int getLegend(){
  157. +       return _legend;
  158. +   }
  159. +  
  160. +   public void setPvpPeriod(int x){
  161. +       _pvpPeriod = x;
  162. +   }
  163. +  
  164. +   public int getPvpPeriod(){
  165. +       return _pvpPeriod;
  166. +   }
  167.     //summon friend
  168.     private SummonRequest _summonRequest = new SummonRequest();
  169.    
  170. @@ -5682,6 +5794,8 @@
  171.             // Add karma to attacker and increase its PK counter
  172.             setPvpKills(getPvpKills() + 1);
  173.            
  174. +           setPvpPeriod(getPvpPeriod() + 1);
  175. +          
  176.             // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  177.             sendPacket(new UserInfo(this));
  178.             sendPacket(new ExBrExtraUserInfo(this));
  179. @@ -7243,6 +7357,10 @@
  180.                 // Set Teleport Bookmark Slot
  181.                 player.setBookMarkSlot(rset.getInt("BookmarkSlot"));
  182.                
  183. +               //Legend
  184. +               player.setLegend(rset.getInt("Legend"));
  185. +               player.setPvpPeriod(rset.getInt("pvp_period"));
  186. +              
  187.                 //character creation Time
  188.                 player.setCreateTime(rset.getLong("createTime"));
  189.                
  190. @@ -7690,7 +7808,9 @@
  191.             statement.setInt(50, getBookMarkSlot());
  192.             statement.setInt(51, getVitalityPoints());
  193.             statement.setString(52, getLang());
  194. -           statement.setInt(53, getObjectId());
  195. +           statement.setInt(53, getLegend());
  196. +           statement.setInt(54, getPvpPeriod());
  197. +           statement.setInt(55, getObjectId());
  198.            
  199.             statement.execute();
  200.             statement.close();
  201. Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
  202. ===================================================================
  203. --- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 4524)
  204. +++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)
  205. @@ -410,6 +410,9 @@
  206.             // no broadcast needed since the player will already spawn dead to others
  207.             sendPacket(new Die(activeChar));
  208.         }
  209. +
  210. +       if(activeChar.getLegend()==1)
  211. +           Announcements.getInstance().announceToAll(activeChar.getName()+", server Legend, has logged into game");
  212.        
  213.         activeChar.onPlayerEnter();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement