version=2796
I am using an Event (Death MAtch) Shared in other forum. All works fine but the players when die don't respawn. (with to village nothing appear, only at the end of the event, they are teleported on the city)
This is all the code DM:
Code: Select all
package net.sf.l2j.gameserver.events; import javolution.util.FastSet;import net.sf.l2j.Config;import net.sf.l2j.gameserver.Announcements;import net.sf.l2j.gameserver.ThreadPoolManager;import net.sf.l2j.gameserver.datatables.MapRegionTable.TeleportWhereType;import net.sf.l2j.gameserver.model.L2World;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import net.sf.l2j.gameserver.model.entity.TvTEvent;import net.sf.l2j.gameserver.network.serverpackets.CreatureSay; /** * * @author DrHouse */public class DeathMatch extends Thread{ private static boolean _scheduled = false; private static volatile Status _status = Status.SLEEPING; private static final FastSet<L2PcInstance> _players = new FastSet<L2PcInstance>(); private static final DeathMatch _instance = new DeathMatch(); // config values private static final int MAX_PLAYERS = 100; private static final int X = 153568; // HERE ok private static final int Y = 142077; private static final int Z = -12738; private static final int EVENT_DURATION = 6; // minutes private static final int INITIAL_DELAY = 200000; // minutes private static final int PERIOD_BETWEEN_EVENTS = 200000; // minutes private static final int[] ON_KILL_REWARD = {57,1000}; private static final int[] WINNER_REWARD = {57,10000}; // REWARDS public static enum Status { SLEEPING, REGISTERING, TELEPORTING, RUNNING, REWARDING } public static void pulse() { _instance.notifyAll(); } public void run() { synchronized (this) { if (_status != Status.SLEEPING) return; if (TvTEvent.isStarting() || TvTEvent.isStarted()) { try { wait(Config.TVT_EVENT_RUNNING_TIME*60*1000); } catch (InterruptedException e) {} } _status = Status.REGISTERING; } CreatureSay cs2 = new CreatureSay(0, 18, "", "Automatic Event initiaded."); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs2); CreatureSay cs4 = new CreatureSay(0, 18, "", "Event [Death Match] started!!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs4); CreatureSay cs = new CreatureSay(0, 18, "", "DM Event: 3 minute(s) until registration is closed!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs); CreatureSay cs3 = new CreatureSay(0, 18, "", "Use .dmjoin to set your request !"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs3); try{ Thread.sleep(120*1000); } catch (Exception e){ e.printStackTrace(); } CreatureSay cs5 = new CreatureSay(0, 18, "", "DM Event: 60 secs until registration is closed!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs5); try{ Thread.sleep(45*1000); } catch (Exception e){ e.printStackTrace(); } CreatureSay cs6 = new CreatureSay(0, 18, "", "DM Event: 15 secs until registration is closed!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs6); try{ Thread.sleep(15*1000); } catch (Exception e){ e.printStackTrace(); } CreatureSay cs7 = new CreatureSay(0, 18, "", "DM: Registration period is over. Get ready for the event!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs7); _status = Status.TELEPORTING; try{ Thread.sleep(5*1000); } catch (Exception e){ e.printStackTrace(); } synchronized (_players) // against removing onlogout players etc { for (L2PcInstance player : _players) { //add reset to deaths flag //set status flag to true player.DeathMatchCount = 0; player.OnDeathMatch = true; player.teleToLocation(153568, 142077, -12738, true); player.setPvpFlag(1); player.sendMessage("Teleporting, event will start in 10 seconds"); } } try{ Thread.sleep(5*1000); } catch (Exception e){ e.printStackTrace(); } CreatureSay cs8 = new CreatureSay(0, 18, "", "DM: 5 seconds!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs8); for (int i = 5; i > 0; i--) { CreatureSay cs9 = new CreatureSay(0, 18, "", "DM: "+i+" seconds"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs9); try{ Thread.sleep(1*1000); } catch (Exception e){ e.printStackTrace(); } } CreatureSay cs10 = new CreatureSay(0, 18, "", "DM: GOOOOO!"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs10); _status = Status.RUNNING; try{ Thread.sleep(EVENT_DURATION*60*950); } catch (Exception e){ e.printStackTrace(); } CreatureSay cs11 = new CreatureSay(0, 18, "", "DM Event: Event is about to finalize"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs11); try{ Thread.sleep(EVENT_DURATION*60*50); } catch (Exception e){ e.printStackTrace(); } _status = Status.REWARDING; CreatureSay cs12 = new CreatureSay(0, 18, "", "DM Event: Event Finalized"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs12); L2PcInstance winner = null; synchronized (_players) // against removing onlogout players etc { for (L2PcInstance player : _players) { player.teleToLocation(TeleportWhereType.Town); player.OnDeathMatch = false; player.sendMessage("Event is done"); //calculate winner if (winner == null) winner = player; else if (winner.DeathMatchCount < player.DeathMatchCount) winner = player; } } if (winner != null && winner.isOnline() == 1) { CreatureSay cs13 = new CreatureSay(0, 18, "", winner.getName()+" won event killing you "+winner.DeathMatchCount+" times;"); for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers().values()) if (onlinePlayer.isOnline() == 1) onlinePlayer.sendPacket(cs13); winner.addItem("DEATHMATCHWINNER", WINNER_REWARD[0], WINNER_REWARD[1], null, true); } else Announcements.getInstance().announceToAll("Event ended with no winner :("); _status = Status.SLEEPING; } public static boolean registerPlayer(L2PcInstance player) { if (player == null) return false; if (_status != Status.REGISTERING) return false; synchronized (_players) { if (_players.size() >= DeathMatch.MAX_PLAYERS) return false; return _players.add(player); } } public static boolean onLogout(L2PcInstance player) { if (player == null) return false; player.DeathMatchCount = 0; player.OnDeathMatch = false; synchronized (_players) { return _players.remove(player); } } public static void onKill(L2PcInstance player) { if (isRunning()) player.addItem("DEATH MATCH", ON_KILL_REWARD[0], ON_KILL_REWARD[1], null, true); } public static boolean isRunning() { return (_status == Status.RUNNING); } public static void startEvent() { new Thread(_instance).start(); } public static boolean stopEvent() { if (_status == Status.SLEEPING) return false; try { _instance.interrupt(); return true; } catch(Exception e) { return true; } finally { synchronized(_players){ for (L2PcInstance player : _players) { player.DeathMatchCount = 0; player.OnDeathMatch = false; player.teleToLocation(TeleportWhereType.Town); player.sendMessage("Event ended abnormally"); } _players.clear(); _status = Status.SLEEPING; } } } public synchronized static void scheduleEventAtFixedRate() { if (_scheduled) return; ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable() { public void run() { startEvent(); } }, INITIAL_DELAY*60*1000, PERIOD_BETWEEN_EVENTS*60*1000); } public static boolean onPotionUse(int playerObjectId, final L2PcInstance player) { if (_status != Status.RUNNING) return true; if (!player.OnDeathMatch) return true; return false; } public static boolean onEscapeUse(int id) { if (_status != Status.RUNNING) return true; synchronized(_players) { if (_players.contains(L2World.getInstance().findObject(id))) return false; } return true; } public static boolean doRevive(final L2PcInstance player) { if (_status != Status.RUNNING) return false; if (!player.OnDeathMatch) return false; player.sendMessage("You will be revived within next 5 seconds"); ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() { public void run() { player.doRevive(); player.setCurrentCp(player.getMaxCp()); player.setCurrentHpMp(player.getMaxHp(),player.getMaxMp()); player.teleToLocation(153568, 142077, -12738, true); player.setPvpFlag(1); } }, 3000); return true; } public void run(final L2PcInstance player) { if (_status != Status.RUNNING) return; if (!player.OnDeathMatch) return; player.doRevive(); player.setCurrentCp(player.getMaxCp()); player.setCurrentHpMp(player.getMaxHp(),player.getMaxMp()); player.teleToLocation(153568, 142077, -12738, true); player.setPvpFlag(1); } }
Code: Select all
public static boolean doRevive(final L2PcInstance player) { if (_status != Status.RUNNING) return false; if (!player.OnDeathMatch) return false; player.sendMessage("You will be revived within next 5 seconds"); ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() { public void run() { player.doRevive(); player.setCurrentCp(player.getMaxCp()); player.setCurrentHpMp(player.getMaxHp(),player.getMaxMp()); player.teleToLocation(153568, 142077, -12738, true); player.setPvpFlag(1); } }, 3000); return true; }

ps: Sry if i must post in section "Custom", but in this section there are the problem of install, upgrade ecc ecc