Advertisement
Guest User

zone name system (UPDATED)

a guest
Nov 14th, 2012
608
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 1 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.zone.type;
  16.  
  17. import java.sql.Connection;
  18. import java.sql.PreparedStatement;
  19. import java.sql.ResultSet;
  20. import java.util.Random;
  21. import java.util.logging.Level;
  22.  
  23. import com.l2jserver.L2DatabaseFactory;
  24. import com.l2jserver.gameserver.ThreadPoolManager;
  25. import com.l2jserver.gameserver.model.actor.L2Character;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.util.Rnd;
  28.  
  29. /**
  30. * An Custom PvP Zone
  31. * @author NeverMore
  32. */
  33. public class L2CustomPvP extends L2RespawnZone
  34. {
  35.  
  36. // Ramdom Locations configs
  37. L2PcInstance activeChar;
  38. private static int[] _x =
  39. {
  40. 11551,
  41. 10999,
  42. 10401
  43. };
  44. private static int[] _y =
  45. {
  46. -24264,
  47. -23576,
  48. -24030
  49. };
  50. private static int[] _z =
  51. {
  52. -3644,
  53. -3651,
  54. -3660
  55. };
  56.  
  57. public L2CustomPvP(int id)
  58. {
  59. super(5555);
  60. }
  61.  
  62.  
  63.  
  64. @Override
  65. protected void onEnter(L2Character character)
  66. {
  67.  
  68. if (character instanceof L2PcInstance)
  69. {
  70. Random r = new Random();
  71. activeChar.setName(""+r.nextInt());
  72. activeChar.setClan(null);
  73. activeChar.getClan().setCrestId(0);
  74. ((L2PcInstance) character).sendMessage("You entered a PvP Area");
  75. ((L2PcInstance) character).setPvpFlag(1);
  76. }
  77. }
  78.  
  79. @Override
  80. protected void onExit(L2Character character)
  81. {
  82.  
  83. if (character instanceof L2PcInstance)
  84. {
  85. activeChar.setName(activeChar.getName());
  86. activeChar.setClan(activeChar.getClan());
  87. activeChar.getClan().setCrestId(activeChar.getClanCrestId());
  88. ((L2PcInstance) character).stopNoblesseBlessing(null);
  89. ((L2PcInstance) character).setPvpFlag(0);
  90. ((L2PcInstance) character).sendMessage("You exit from a PvP Area");
  91. }
  92. }
  93.  
  94. static class BackToPvp implements Runnable
  95. {
  96. private final L2Character _activeChar;
  97.  
  98. BackToPvp(L2Character character)
  99. {
  100. _activeChar = character;
  101. }
  102.  
  103. @SuppressWarnings("synthetic-access")
  104. @Override
  105. public void run()
  106. {
  107. int r = Rnd.get(3);
  108. _activeChar.teleToLocation(_x[r], _y[r], _z[r]);
  109. }
  110. }
  111.  
  112. @Override
  113. public void onDieInside(L2Character character)
  114. {
  115. if (character instanceof L2PcInstance)
  116. {
  117. }
  118. }
  119.  
  120. @Override
  121. public void onReviveInside(L2Character character)
  122. {
  123. ThreadPoolManager.getInstance().scheduleGeneral(new BackToPvp(character), 500);
  124. ((L2PcInstance) character).isNoblesseBlessed();
  125. }
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement