Jump to content
  • 0

Question

Posted (edited)

Gia sas simera evala tvt se jacis pack ola koble mia xara den m vgike kanena problem alla otan bika sto game kai arxise to registartion elege ayto

b6V9V2F.png

 

elege sto announcements ayto "Registrations for the TvT Event are opened for 2 minutes. Type /join to register and /leave to WITHDRAW"

alla otan to dokimasa na patiso /join den m elege tpt oute oti ekana register opos tin eikona edw 

thNPGwj.png

kanonika leei "You have registered successfully" otan patas /join emena den m elege tpt kai den ekane register sto event to idio kai me to /leave kanena apo ta dio den douleve kseri kanis ti fteei? i an einai anti gia /join na ta kano .join i .tvtjoin oti einai pio efkolo na gini pls :| 

Edited by Anuvor

Recommended Posts

  • 0
Posted

Νομίζω χρειάζεται να δηλώσεις τα Commands αν δε κάνω λάθος για να δουλέψουν...

Στείλε λίγο το link από το Event που θες...

  • 0
Posted

Νομίζω χρειάζεται να δηλώσεις τα Commands αν δε κάνω λάθος για να δουλέψουν...

Στείλε λίγο το link από το Event που θες...

apo jbrasil to vrika thes na s stilo to link apo ekei?

  • 0
Posted

Δεν με αφήνει να δω το topic.

Στείλε μου το περιεχόμενό του με


 
### Eclipse Workspace Patch 1.0

#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java (wersja 16)
+++ java/net/sf/l2j/gameserver/GameServer.java (kopia robocza)
@@ -58,6 +58,7 @@
import net.sf.l2j.gameserver.datatables.StaticObjects;
import net.sf.l2j.gameserver.datatables.SummonItemsData;
import net.sf.l2j.gameserver.datatables.TeleportLocationTable;
+import net.sf.l2j.gameserver.events.EventManager;
import net.sf.l2j.gameserver.handler.AdminCommandHandler;
import net.sf.l2j.gameserver.handler.ChatHandler;
import net.sf.l2j.gameserver.handler.ItemHandler;
@@ -290,6 +291,9 @@
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
FishingChampionshipManager.getInstance();

+ Util.printSection("Event Manager");
+ EventManager.getInstance();
+
Util.printSection("System");
TaskManager.getInstance();

Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (wersja 16)
+++ java/net/sf/l2j/Config.java (kopia robocza)
@@ -24,6 +24,7 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -251,6 +252,14 @@
public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;

+ /** TvT Event */
+ public static boolean ALLOW_TVT_EVENT;
+ public static String TVT_EVENT_TIMES;
+ public static HashMap<Integer, Integer> TVT_EVENT_REWARDS = new HashMap<>();
+ public static HashMap<String, int[]> TVT_TEAMS_DATA = new HashMap<>();
+ public static int TVT_RES_SECONDS;
+ public static ArrayList<Integer> TVT_DOORS = new ArrayList<>();
+
// --------------------------------------------------
// HexID
// --------------------------------------------------
@@ -886,6 +895,38 @@
ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);

+ ALLOW_TVT_EVENT = events.getProperty("AllowTvtEvent", false);
+ TVT_EVENT_TIMES = events.getProperty("TvtEventTimes", "12:00,14:00,16:00");
+ String TVT_EVENT_REWARDS_VALUE = events.getProperty("TvtEventRewards", "57,1;");
+ String[] tvt_event_rewards_splitted_1 = TVT_EVENT_REWARDS_VALUE.split(";");
+ for (String i : tvt_event_rewards_splitted_1)
+ {
+ String[] tvt_event_rewards_splitted_2 = i.split(",");
+ TVT_EVENT_REWARDS.put(Integer.parseInt(tvt_event_rewards_splitted_2[0]),
+	 Integer.parseInt(tvt_event_rewards_splitted_2[1]));
+ }
+ String tvt_teams_data = events.getProperty("TvtTeamsData", "Good_0,0,0;Evil_0,0,0");
+ String[] ttd_splitted = tvt_teams_data.split(";");
+ for (String s : ttd_splitted)
+ {
+ String[] ss = s.split("_");
+ String name = ss[0];
+ String[] sss = ss[1].split(",");
+ int x = Integer.parseInt(sss[0]);
+ int y = Integer.parseInt(sss[1]);
+ int z = Integer.parseInt(sss[2]);
+
+ TVT_TEAMS_DATA.put(name, new int[] { x, y, z });
+ }
+ TVT_RES_SECONDS = events.getProperty("TvtResSeconds", 10);
+ String tvt_doors = events.getProperty("TvtDoors", "24190001,24190002,24190003,24190004");
+ String[] tvt_doors_split = tvt_doors.split(",");
+ for (String s : tvt_doors_split)
+ {
+ int i = Integer.parseInt(s);
+ TVT_DOORS.add(i);
+ }
+
// FloodProtector
ExProperties security = load(FLOOD_PROTECTOR_FILE);
loadFloodProtectorConfig(security, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
Index: java/net/sf/l2j/gameserver/events/TvTEvent.java
===================================================================
--- java/net/sf/l2j/gameserver/events/TvTEvent.java (wersja 0)
+++ java/net/sf/l2j/gameserver/events/TvTEvent.java (wersja 0)
@@ -0,0 +1,239 @@
+/*
+ * This program is FREE SOFTWARE: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the FREE Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.events;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.datatables.DoorTable;
+import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Anarchy
+ */
+public class TvTEvent implements IEvent
+{
+ public ArrayList<L2PcInstance> _players;
+ private EventState _state = EventState.INACTIVE;
+ private final ArrayList<EventTeam> _teams;
+ private final ArrayList<L2DoorInstance> _doors;
+
+ public TvTEvent()
+ {
+ _players = new ArrayList<>();
+ _teams = new ArrayList<>();
+ _doors = new ArrayList<>();
+ }
+
+ @Override
+ public void runEvent()
+ {
+ if (EventManager.getInstance().getCurrentEvent() != null)
+ {
+ return;
+ }
+
+ EventManager.getInstance().setCurrentEvent(this);
+
+ Announcements.announceToAll("Registrations for the TvT Event are opened for 2 minutes. Type /join to register and /leave to withdraw.");
+ _state = EventState.REGISTERING;
+
+ sleep(120);
+
+ if (!check())
+ {
+ EventManager.getInstance().setCurrentEvent(null);
+ return;
+ }
+
+ Announcements.announceToAll("Registrations for the TvT Event are closed. Teams will be teleported in 10 seconds.");
+ _state = EventState.RUNNING;
+
+ sleep(10);
+
+ split();
+
+ for (EventTeam et : _teams)
+ {
+ et.teleportTeam(Config.TVT_TEAMS_DATA.get(et.getName())[0], Config.TVT_TEAMS_DATA.get(et.getName())[1], Config.TVT_TEAMS_DATA.get(et.getName())[2], true);
+
+ et.paralize(true);
+ }
+ closeDoors();
+ Announcements.announceToAll("Teams have been teleported. Fight begins in 5 seconds.");
+
+ sleep(5);
+
+ for (EventTeam et : _teams)
+ {
+ et.paralize(false);
+ }
+ Announcements.announceToAll("The fight has started!");
+ Announcements.announceToAll("The event will last for 1 minute(s).");
+
+ sleep(60); // tvt time in sec
+
+ rewardAndClear();
+ openDoors();
+ _state = EventState.INACTIVE;
+
+ EventManager.getInstance().setCurrentEvent(null);
+ }
+
+ private void openDoors()
+ {
+ if (_doors.isEmpty())
+ {
+ for (int i : Config.TVT_DOORS)
+ {
+ L2DoorInstance door = DoorTable.getInstance().getDoor(i);
+ door.openMe();
+ }
+ }
+ else
+ {
+ for (L2DoorInstance door : _doors)
+ {
+ door.deleteMe();
+ }
+ }
+ }
+
+ private static void closeDoors()
+ {
+ for (int i : Config.TVT_DOORS)
+ {
+ L2DoorInstance door = DoorTable.getInstance().getDoor(i);
+ door.closeMe();
+ }
+ }
+
+ public void rewardAndClear()
+ {
+ int i = 0;
+ EventTeam WINNER = null;
+
+ for (EventTeam et : _teams)
+ {
+ et.teleportTeam(82698, 148638, -3473, true);
+
+ for (L2PcInstance p : et.getPlayers())
+ {
+ EventCommons.getInstance().removePlayer(p);
+ }
+
+ if (et.getPoints() > i)
+ {
+ i = et.getPoints();
+ winner = et;
+ }
+ }
+
+ if (winner != null)
+ {
+ for (int ii : Config.TVT_EVENT_REWARDS.keySet())
+ {
+ winner.rewardTeam(ii, Config.TVT_EVENT_REWARDS.get(ii));
+ }
+
+ Announcements.announceToAll(winner.getName() + " team has won the event.");
+ }
+ else
+ Announcements.announceToAll("Event ended with no winner.");
+ return;
+ }
+
+ public boolean check()
+ {
+ if (EventCommons.getInstance().getRegisteredPlayersSize(TvTEvent.class) < Config.TVT_TEAMS_DATA.size() * 1)
+ {
+ Announcements.announceToAll("The event has been canceled due to lack of participants.");
+ EventCommons.getInstance().removeRegisteredPlayers(TvTEvent.class);
+ _state = EventState.INACTIVE;
+ return false;
+ }
+
+ return true;
+ }
+
+ public void split()
+ {
+ int i = Config.TVT_TEAMS_DATA.size() - 1;
+ LinkedList<LinkedList<L2PcInstance>> temp = new LinkedList<>();
+
+ for (int ii = Config.TVT_TEAMS_DATA.size(); ii > 0; ii--)
+ {
+ LinkedList<L2PcInstance> t = new LinkedList<>();
+ temp.add(t);
+ }
+
+ for (L2PcInstance p : EventCommons.getInstance().getRegisteredPlayers(TvTEvent.class))
+ {
+ temp.get(i).add(p);
+ i--;
+
+ if (i == -1)
+ {
+ i = Config.TVT_TEAMS_DATA.size();
+ }
+
+ EventCommons.getInstance().addPlayer(p, this);
+ }
+
+ for (String s : Config.TVT_TEAMS_DATA.keySet())
+ {
+ EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
+ {
+ Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
+ });
+ temp.remove(temp.getLast());
+
+ _teams.add(et);
+ }
+ }
+
+ private static void sleep(int seconds)
+ {
+ try
+ {
+ Thread.sleep(seconds * 1000);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public EventState getState()
+ {
+ return _state;
+ }
+
+ @Override
+ public String getTimes()
+ {
+ return Config.TVT_EVENT_TIMES;
+ }
+
+ @Override
+ public int getId()
+ {
+ return 1;
+ }
+}
Index: config/events.properties
===================================================================
--- config/events.properties (wersja 16)
+++ config/events.properties (kopia robocza)
@@ -251,4 +251,22 @@
AltFishChampionshipReward2 = 500000
AltFishChampionshipReward3 = 300000
AltFishChampionshipReward4 = 200000
-AltFishChampionshipReward5 = 100000
\ No newline at end of file
+AltFishChampionshipReward5 = 100000
+
+#=============================================================
+#					 TvT Event
+#=============================================================
+# Enable or disable the TvT Event.
+AllowTvtEvent = True
+# Times of day that the event will take place.
+TvtEventTimes = 12:00,14:00,16:00
+# Rewards.
+TvtEventRewards = 57,1000;
+# Team data. Should be like this: teamname_x,y,z;teamname_x,y,z.
+# Note: You can add as many teams as you like.
+TvtTeamsData = Angels_148404,46718,-3414;Demons_150545,46718,-3414
+# Time to res after death.
+TvtResSeconds = 5
+# Doors to close when event starts.
+# Default doors: Coliseum
+TvtDoors = 24190001,24190002,24190003,24190004
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (wersja 16)
+++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (kopia robocza)
@@ -15,6 +15,7 @@
package net.sf.l2j.gameserver.network.serverpackets;

import net.sf.l2j.gameserver.datatables.AccessLevels;
+import net.sf.l2j.gameserver.events.EventCommons;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
import net.sf.l2j.gameserver.model.L2AccessLevel;
import net.sf.l2j.gameserver.model.L2Clan;
@@ -58,7 +59,14 @@

writeC(0x06);
writeD(_charObjId);
- writeD(0x01); // to nearest village
+ if (_activeChar instanceof L2PcInstance && EventCommons.getInstance().showDiePacket((L2PcInstance)_activeChar))
+ {
+ writeD(0x01); // to nearest village
+ }
+ else
+ {
+ writeD(0x00);
+ }

if (_clan != null)
{
Index: java/net/sf/l2j/gameserver/events/EventCommons.java
===================================================================
--- java/net/sf/l2j/gameserver/events/EventCommons.java (wersja 0)
+++ java/net/sf/l2j/gameserver/events/EventCommons.java (wersja 0)
@@ -0,0 +1,274 @@
+/*
+ * This program is FREE software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the FREE SOFTWARE
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.events;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.actor.L2Character;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+
+/**
+ * @author Anarchy
+ *
+ *This class contains restrictions and general methods for all events.
+ */
+public final class EventCommons
+{
+ public final HashMap<L2PcInstance, IEvent> _players;
+ private final HashMap<L2PcInstance, Class<?>> _registeredPlayers;
+
+ public static EventCommons getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ protected EventCommons()
+ {
+ _players = new HashMap<>();
+ _registeredPlayers = new HashMap<>();
+ }
+
+ public void registerPlayer(L2PcInstance player, Class<?> c)
+ {
+ if (_registeredPlayers.containsKey(player))
+ {
+ player.sendMessage("You have already registered for the event.");
+ return;
+ }
+
+ _registeredPlayers.put(player, c);
+ }
+
+ public void unregisterPlayer(L2PcInstance player, Class<?> c)
+ {
+ if (!_registeredPlayers.containsKey(player))
+ {
+ player.sendMessage("You have not registered for the event.");
+ return;
+ }
+
+ _registeredPlayers.remove(player);
+ }
+
+ public boolean showDiePacket(L2PcInstance player)
+ {
+ if (_players.containsKey(player))
+ {
+ if (_players.get(player) instanceof TvTEvent)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public boolean canUnstuck(L2PcInstance player)
+ {
+ if (_players.containsKey(player))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean canRes(L2PcInstance victim)
+ {
+ if (_players.containsKey(victim))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean canRecall(L2PcInstance victim)
+ {
+ if (_players.containsKey(victim))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public void doDie(L2Character killer, L2PcInstance victim)
+ {
+ if (_players.containsKey(victim))
+ {
+ if (killer != null && killer instanceof L2PcInstance)
+ {
+ L2PcInstance kl = (L2PcInstance)killer;
+
+ if (_players.containsKey(kl))
+ {
+	 if (_players.get(victim) == _players.get(kl))
+	 {
+	 // TvT event kills.
+	 if (_players.get(victim) instanceof TvTEvent)
+	 {
+	 if (kl.getEventTeam() != victim.getEventTeam())
+	 {
+	 kl.getEventTeam().addPoints(1);
+	 }
+	
+	 ThreadPoolManager.getInstance().scheduleGeneral(new ResTask(victim.getEventTeam().getRespawnX(), victim.getEventTeam().getRespawnY(), victim.getEventTeam().getRespawnZ(), victim, true),Config.TVT_RES_SECONDS * 1000);
+	 }
+	 }
+ }
+ }
+ }
+ }
+
+ public boolean canTarget(L2PcInstance player, L2PcInstance target)
+ {
+ if ((!_players.containsKey(player) && _players.containsKey(target))
+ || (_players.containsKey(player) && !_players.containsKey(target)))
+ {
+ player.setTarget(null);
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ return false;
+ }
+
+ if (_players.get(player) != _players.get(target))
+ {
+ player.setTarget(null);
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ return false;
+ }
+
+ if ((target.getEventTeam() != null && player.getEventTeam() == null))
+ {
+ player.setTarget(null);
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ return false;
+ }
+
+ if (target.getEventTeam() == null && player.getEventTeam() != null)
+ {
+ player.setTarget(null);
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ return false;
+ }
+
+ return true;
+ }
+
+ public void addPlayer(L2PcInstance player, IEvent event)
+ {
+ if (!_players.containsKey(player))
+ {
+ _players.put(player, event);
+ }
+ }
+
+ public void removePlayer(L2PcInstance player)
+ {
+ if (_players.containsKey(player))
+ {
+ _players.remove(player);
+ }
+ }
+
+ public int getRegisteredPlayersSize(Class<?> c)
+ {
+ int i = 0;
+ for (L2PcInstance p : _registeredPlayers.keySet())
+ {
+ if (_registeredPlayers.get(p) == c)
+ {
+ i++;
+ }
+ }
+
+ return i;
+ }
+
+ public void removeRegisteredPlayers(Class<?> c)
+ {
+ ArrayList<L2PcInstance> temp = new ArrayList<>();
+
+ for (L2PcInstance p : _registeredPlayers.keySet())
+ {
+ if (_registeredPlayers.get(p) == c)
+ {
+ temp.add(p);
+ }
+ }
+
+ for (L2PcInstance p : temp)
+ {
+ _registeredPlayers.remove(p);
+ }
+ }
+
+ public HashMap<L2PcInstance, Class<?>> getRegisteredPlayers()
+ {
+ return _registeredPlayers;
+ }
+
+ public ArrayList<L2PcInstance> getRegisteredPlayers(Class<?> c)
+ {
+ ArrayList<L2PcInstance> temp = new ArrayList<>();
+
+ for (L2PcInstance p : _registeredPlayers.keySet())
+ {
+ if (_registeredPlayers.get(p) == c)
+ {
+ temp.add(p);
+ }
+ }
+
+ return temp;
+ }
+
+ public class ResTask implements Runnable
+ {
+ private final int _x, _y, _z;
+ private final L2PcInstance _player;
+ private final boolean _heal;
+
+ public ResTask(int x, int y, int z, L2PcInstance player, boolean heal)
+ {
+ _x = x;
+ _y = y;
+ _z = z;
+ _player = player;
+ _heal = heal;
+ }
+
+ @Override
+ public void run()
+ {
+ _player.doRevive();
+ _player.teleToLocation(_x, _y, _z, 0);
+ if (_heal)
+ {
+ _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
+ _player.setCurrentCp(_player.getMaxCp());
+ }
+ }
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final EventCommons _instance = new EventCommons();
+ }
+}
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (wersja 16)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (kopia robocza)
@@ -66,6 +66,8 @@
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
import net.sf.l2j.gameserver.datatables.SkillTreeTable;
+import net.sf.l2j.gameserver.events.EventCommons;
+import net.sf.l2j.gameserver.events.EventTeam;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.handler.ItemHandler;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
@@ -250,6 +252,18 @@
*/
public final class L2PcInstance extends L2Playable
{
+ private EventTeam _eventTeam = null;
+
+ public EventTeam getEventTeam()
+ {
+ return _eventTeam;
+ }
+
+ public void setEventTeam(EventTeam val)
+ {
+ _eventTeam = val;
+ }
+
// Character Skill SQL String Definitions:
private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
@@ -3319,6 +3333,10 @@
@Override
public void onAction(L2PcInstance player)
{
+ if (!EventCommons.getInstance().canTarget(player, this))
+ {
+ return;
+ }
// Check if the player already target this L2PcInstance
if (player.getTarget() != this)
{
@@ -4078,6 +4096,8 @@
	 stopFakeDeath(true);
}

+ EventCommons.getInstance().doDie(killer, this);
+
if (killer != null)
{
L2PcInstance pk = killer.getActingPlayer();
Index: java/net/sf/l2j/gameserver/events/IEvent.java
===================================================================
--- java/net/sf/l2j/gameserver/events/IEvent.java (wersja 0)
+++ java/net/sf/l2j/gameserver/events/IEvent.java (wersja 0)
@@ -0,0 +1,29 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.events;
+
+/**
+ * @author Anarchy
+ */
+public interface IEvent
+{
+ public void runEvent();
+
+ public EventState getState();
+
+ public String getTimes();
+
+ public int getId();
+}
Index: java/net/sf/l2j/gameserver/events/EventState.java
===================================================================
--- java/net/sf/l2j/gameserver/events/EventState.java (wersja 0)
+++ java/net/sf/l2j/gameserver/events/EventState.java (wersja 0)
@@ -0,0 +1,27 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.events;
+
+/**
+ * @author Anarchy
+ *
+ * This class should contain all the necessary states for an event.
+ */
+public enum EventState
+{
+ INACTIVE,
+ REGISTERING,
+ RUNNING
+}
Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (wersja 16)
+++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (kopia robocza)
@@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;

+import net.sf.l2j.gameserver.events.EventCommons;
import net.sf.l2j.gameserver.handler.ISkillHandler;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Skill;
@@ -56,6 +57,9 @@
	 if (player.getClanId() != ((L2PcInstance) target).getClanId())
	 continue;
	 }
+
+ if (!EventCommons.getInstance().canRes((L2PcInstance)target))
+	 continue;
}

if (target.isVisible())
Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (wersja 0)
+++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (wersja 0)
@@ -0,0 +1,67 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.handler.usercommandhandlers;
+
+import net.sf.l2j.gameserver.events.EventCommons;
+import net.sf.l2j.gameserver.events.EventManager;
+import net.sf.l2j.gameserver.events.EventState;
+import net.sf.l2j.gameserver.events.TvTEvent;
+import net.sf.l2j.gameserver.handler.IUserCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Anarchy
+ */
+public class EventCommands implements IUserCommandHandler
+{
+ private static final int[] COMMAND_IDS =
+ {
+ 114, 115
+ };
+
+ @Override
+ public boolean useUserCommand(int id, L2PcInstance activeChar)
+ {
+ if (activeChar.isInOlympiadMode())
+ {
+ return false;
+ }
+
+ if (id == 114)
+ {
+ if (EventManager.getInstance().getCurrentEvent() == null || EventManager.getInstance().getCurrentEvent().getState() != EventState.REGISTERING)
+ return false;
+
+ EventCommons.getInstance().registerPlayer(activeChar, TvTEvent.class);
+ activeChar.sendMessage("You have registered successfully.");
+
+ }
+ else if (id == 115)
+ {
+ if (EventCommons.getInstance().getRegisteredPlayers().containsKey(activeChar))
+ EventCommons.getInstance().unregisterPlayer(activeChar,EventCommons.getInstance().getRegisteredPlayers().get(activeChar));
+
+ activeChar.sendMessage("You have canceled your registration.");
+ }
+
+ return true;
+ }
+
+ @Override
+ public int[] getUserCommandList()
+ {
+ return COMMAND_IDS;
+ }
+}
Index: java/net/sf/l2j/gameserver/events/EventTeam.java
===================================================================
--- java/net/sf/l2j/gameserver/events/EventTeam.java (wersja 0)
+++ java/net/sf/l2j/gameserver/events/EventTeam.java (wersja 0)
@@ -0,0 +1,128 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.events;
+
+import java.util.List;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.skills.AbnormalEffect;
+
+/**
+ * @author Anarchy
+ *
+ */
+public class EventTeam
+{
+ private final List<L2PcInstance> _players;
+ private final String _name;
+ private int _points;
+ private final int[] _respawnLoc;
+
+ public EventTeam(List<L2PcInstance> players, String name, int points, int[] respawnLoc)
+ {
+ _players = players;
+ _name = name;
+ _points = points;
+ _respawnLoc = respawnLoc;
+
+ for (L2PcInstance p : _players)
+ {
+ p.setEventTeam(this);
+ }
+ }
+
+ public void teleportTeam(int x, int y, int z, boolean sendMessage)
+ {
+ for (L2PcInstance p : _players)
+ {
+ p.teleToLocation(x, y, z, 1);
+ if (sendMessage)
+ p.sendMessage("You have been teleported.");
+ }
+ }
+
+ public void paralize(boolean val)
+ {
+ if (val)
+ {
+ for (L2PcInstance p : _players)
+ {
+ p.startAbnormalEffect(AbnormalEffect.ROOT);
+ p.setIsParalyzed(true);
+ }
+ }
+ else
+ {
+ for (L2PcInstance p : _players)
+ {
+ p.stopAbnormalEffect(AbnormalEffect.ROOT);
+ p.setIsParalyzed(false);
+ }
+ }
+ }
+
+ public void rewardTeam(int itemId, int count)
+ {
+ for (L2PcInstance p : _players)
+ {
+ p.addItem("Event Reward", itemId, count, null, true);
+ }
+ }
+
+ public void addPoints(int val)
+ {
+ _points += val;
+ }
+
+ public void removePoints(int val)
+ {
+ _points -= val;
+ }
+
+ public int getPoints()
+ {
+ return _points;
+ }
+
+ public int getRespawnX()
+ {
+ return _respawnLoc[0];
+ }
+
+ public int getRespawnY()
+ {
+ return _respawnLoc[1];
+ }
+
+ public int getRespawnZ()
+ {
+ return _respawnLoc[2];
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public List<L2PcInstance> getPlayers()
+ {
+ return _players;
+ }
+
+ public boolean containsPlayer(L2PcInstance p)
+ {
+ return _players.contains(p);
+ }
+}
Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (wersja 16)
+++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (kopia robocza)
@@ -15,6 +15,7 @@
package net.sf.l2j.gameserver.handler.usercommandhandlers;

import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.events.EventCommons;
import net.sf.l2j.gameserver.handler.IUserCommandHandler;
import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
@@ -31,7 +32,7 @@
@Override
public boolean useUserCommand(int id, L2PcInstance activeChar)
{
- if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || GrandBossManager.isInBossZone(activeChar))
+ if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || GrandBossManager.isInBossZone(activeChar)|| !EventCommons.getInstance().canUnstuck(activeChar))
{
activeChar.sendMessage("Your current state doesn't allow you to use the /unstuck command.");
return false;
Index: java/net/sf/l2j/gameserver/events/EventManager.java
===================================================================
--- java/net/sf/l2j/gameserver/events/EventManager.java (wersja 0)
+++ java/net/sf/l2j/gameserver/events/EventManager.java (wersja 0)
@@ -0,0 +1,144 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.events;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.logging.Logger;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+
+/**
+ * @author Anarchy
+ *
+ * Just a class that will handle the registering and loading of events.
+ */
+public final class EventManager
+{
+ private static final Logger _log = Logger.getLogger(EventManager.class.getName());
+
+ public static int TVT = 1;
+
+ private int _events = 0;
+ public HashMap<IEvent, Integer> _eventsTasks;
+ private IEvent _currentEvent = null;
+
+ public static EventManager getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ protected EventManager()
+ {
+ _eventsTasks = new HashMap<>();
+
+ if (Config.ALLOW_TVT_EVENT)
+ registerEvent(Config.TVT_EVENT_TIMES, TvTEvent.class);
+
+ _log.info("Loaded " + _events + " events.");
+ }
+
+ public void registerEvent(final String times, final Class<?> type)
+ {
+ _events++;
+
+ int i = 0;
+
+ for (String time : times.split(","))
+ {
+ final IEvent event;
+
+ try
+ {
+ event = (IEvent)type.newInstance();
+ }
+ catch (InstantiationException | IllegalAccessException ea)
+ {
+ ea.printStackTrace();
+ return;
+ }
+
+ String[] timeArray = time.split(":");
+ int hours = Integer.parseInt(timeArray[0]);
+ int minutes = Integer.parseInt(timeArray[1]);
+
+ Calendar cld = Calendar.getInstance();
+
+ cld.set(Calendar.HOUR_OF_DAY, hours);
+ cld.set(Calendar.MINUTE, minutes);
+ cld.set(Calendar.SECOND, 0);
+
+ if (cld.getTimeInMillis() - System.currentTimeMillis() < 0)
+ {
+ cld.set(Calendar.DAY_OF_MONTH, cld.get(Calendar.DAY_OF_MONTH) + 1);
+ cld.set(Calendar.HOUR_OF_DAY, hours);
+ cld.set(Calendar.MINUTE, minutes);
+ cld.set(Calendar.SECOND, 0);
+ }
+
+ if (cld.getTimeInMillis() - System.currentTimeMillis() > 0)
+ {
+ i++;
+
+ if (_eventsTasks.containsKey(event))
+ {
+	 _eventsTasks.remove(event);
+	 _eventsTasks.put(event, i);
+ }
+ else
+ {
+	 _eventsTasks.put(event, i);
+ }
+
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+	 @Override
+	 public void run()
+	 {
+	 if (_eventsTasks.get(event) == 1)
+	 {
+	 _eventsTasks.remove(event);
+	 registerEvent(times, type);
+	 }
+	 else
+	 {
+	 int t = _eventsTasks.get(event);
+	 _eventsTasks.remove(event);
+	 _eventsTasks.put(event, t--);
+	 }
+	
+	 event.runEvent();
+	 }
+ }, cld.getTimeInMillis() - System.currentTimeMillis());
+ }
+ }
+ }
+
+ public IEvent getCurrentEvent()
+ {
+ return _currentEvent;
+ }
+
+ public void setCurrentEvent(IEvent event)
+ {
+ _currentEvent = event;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final EventManager _instance = new EventManager();
+ }
+}
Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (wersja 16)
+++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (kopia robocza)
@@ -26,6 +26,7 @@
import net.sf.l2j.gameserver.handler.usercommandhandlers.ClanWarsList;
import net.sf.l2j.gameserver.handler.usercommandhandlers.DisMount;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Escape;
+import net.sf.l2j.gameserver.handler.usercommandhandlers.EventCommands;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Loc;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
@@ -58,6 +59,7 @@
registerUserCommandHandler(new ChannelLeave());
registerUserCommandHandler(new ChannelDelete());
registerUserCommandHandler(new ChannelListUpdate());
+ registerUserCommandHandler(new EventCommands());
}

public void registerUserCommandHandler(IUserCommandHandler handler)
Index: java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java (wersja 16)
+++ java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java (kopia robocza)
@@ -14,6 +14,7 @@
*/
package net.sf.l2j.gameserver.handler.skillhandlers;

+import net.sf.l2j.gameserver.events.EventCommons;
import net.sf.l2j.gameserver.handler.ISkillHandler;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Skill;
@@ -43,6 +44,9 @@
if (victim == null || victim.isAlikeDead())
	 continue;

+ if (!EventCommons.getInstance().canRecall(victim))
+ continue;
+
victim.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
}
}
[*]

  • 0
Posted (edited)

Αυτό το κομμάτι το έχεις κάνει?

 

Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (wersja 16)
+++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (kopia robocza)
@@ -26,6 +26,7 @@
import net.sf.l2j.gameserver.handler.usercommandhandlers.ClanWarsList;
import net.sf.l2j.gameserver.handler.usercommandhandlers.DisMount;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Escape;
+import net.sf.l2j.gameserver.handler.usercommandhandlers.EventCommands;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Loc;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
@@ -58,6 +59,7 @@
registerUserCommandHandler(new ChannelLeave());
registerUserCommandHandler(new ChannelDelete());
registerUserCommandHandler(new ChannelListUpdate());
+ registerUserCommandHandler(new EventCommands());
}
Edited by 'Baggos'
  • 0
Posted (edited)

http://www.maxcheaters.com/topic/172697-tvt-event/

 

I have no idea what did you said, but client part probably.. :D

Do not work the /join or /leave.

Everything is ok but this commands no. :P

 

This one(SweeTs code) is better code Anuvor... Give a try here...

Edited by 'Baggos'
  • 0
Posted

 

Αυτό το κομμάτι το έχεις κάνει?

Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (wersja 16)
+++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (kopia robocza)
@@ -26,6 +26,7 @@
import net.sf.l2j.gameserver.handler.usercommandhandlers.ClanWarsList;
import net.sf.l2j.gameserver.handler.usercommandhandlers.DisMount;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Escape;
+import net.sf.l2j.gameserver.handler.usercommandhandlers.EventCommands;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Loc;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
@@ -58,6 +59,7 @@
registerUserCommandHandler(new ChannelLeave());
registerUserCommandHandler(new ChannelDelete());
registerUserCommandHandler(new ChannelListUpdate());
+ registerUserCommandHandler(new EventCommands());
}

nai to exo 

  • 0
Posted (edited)

nai to exo 

Πήγαινε στο System σου, κάνε edit με το FileEdit το αρχείο commandname-e.dat και βάλε 2 νέες γραμμές με τα ID:

114 115

Edited by 'Baggos'
  • 0
Posted

Πήγαινε στο System σου, κάνε edit με το FileEdit το αρχείο commandname-e.dat και βάλε 2 νέες γραμμές με τα ID:

114 115

 

yparxoun idi ti na kano?7fSj4Rg.png

  • 0
Posted

Πήγαινε στον κώδικα EventCommands.java και κάνε αλλαγή στα παρακάτω:

 

public class EventCommands implements IUserCommandHandler
{
       private static final int[] COMMAND_IDS =
       {
-               114, 115
+               115, 116
       };
 
 
-               if (id == 114)
+               if (id == 115)
               {
                       if (EventManager.getInstance().getCurrentEvent() == null || EventManager.getInstance().getCurrentEvent().getState() != EventState.REGISTERING)
                               return false;
                    
                       EventCommons.getInstance().registerPlayer(activeChar, TvTEvent.class);
                       activeChar.sendMessage("You have registered successfully.");

               }
-               else if (id == 115)
+               else if (id == 116)
               {
                       if (EventCommons.getInstance().getRegisteredPlayers().containsKey(activeChar))

 

Και στο commandname-e.dat σου να γίνει έτσι:

 

116 115 join
117 116 leave

 

Για δοκίμασε...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...