Advertisement
Guest User

custom name zone

a guest
Nov 14th, 2012
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 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. ((L2PcInstance) character).sendMessage("You entered a PvP Area");
  73. ((L2PcInstance) character).setPvpFlag(1);
  74. }
  75. }
  76.  
  77. @Override
  78. protected void onExit(L2Character character)
  79. {
  80.  
  81. if (character instanceof L2PcInstance)
  82. {
  83. activeChar.setName(activeChar.getName());
  84. ((L2PcInstance) character).stopNoblesseBlessing(null);
  85. ((L2PcInstance) character).setPvpFlag(0);
  86. ((L2PcInstance) character).sendMessage("You exit from a PvP Area");
  87. }
  88. }
  89.  
  90. static class BackToPvp implements Runnable
  91. {
  92. private final L2Character _activeChar;
  93.  
  94. BackToPvp(L2Character character)
  95. {
  96. _activeChar = character;
  97. }
  98.  
  99. @SuppressWarnings("synthetic-access")
  100. @Override
  101. public void run()
  102. {
  103. int r = Rnd.get(3);
  104. _activeChar.teleToLocation(_x[r], _y[r], _z[r]);
  105. }
  106. }
  107.  
  108. @Override
  109. public void onDieInside(L2Character character)
  110. {
  111. if (character instanceof L2PcInstance)
  112. {
  113. }
  114. }
  115.  
  116. @Override
  117. public void onReviveInside(L2Character character)
  118. {
  119. ThreadPoolManager.getInstance().scheduleGeneral(new BackToPvp(character), 500);
  120. ((L2PcInstance) character).isNoblesseBlessed();
  121. }
  122.  
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement