Jump to content
  • 0

Error Fight Club Event!


Question

Posted
Hello,

 

When i launch the Fight Club event, players spawn well but remain stuck to the ground, then nothing, here's the mistake:

 

mini_316762erreur.png

 

If you can help me please, thank you very much.  :-[

 

   

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

Here is the code FightClubArena.java:

package events.FightClub;

import l2r.commons.threading.RunnableImpl;
import l2r.commons.util.Rnd;
import l2r.gameserver.Config;
import l2r.gameserver.ThreadPoolManager;
import l2r.gameserver.data.xml.holder.InstantZoneHolder;
import l2r.gameserver.listener.actor.OnDeathListener;
import l2r.gameserver.listener.actor.player.OnPlayerExitListener;
import l2r.gameserver.model.Creature;
import l2r.gameserver.model.Player;
import l2r.gameserver.model.actor.listener.CharListenerList;
import l2r.gameserver.model.base.TeamType;
import l2r.gameserver.model.entity.Reflection;
import l2r.gameserver.model.instances.DoorInstance;

import l2r.gameserver.templates.InstantZone;

import l2r.gameserver.utils.ItemFunctions;

import java.util.concurrent.ScheduledFuture;

public class FightClubArena extends FightClubManager implements OnDeathListener, OnPlayerExitListener
{
	protected static final String CLASS_NAME = "events.FightClub.FightClubManager";

	private ScheduledFuture<?> _endTask;
	public static ScheduledFuture<?> _startTask;

	private boolean _isEnded = false;
	private Player _player1;
	private Player _player2;
	private static int _itemId;
	private static int _itemCount;
	private static Reflection _reflection;
	private InstantZone _instantZone = InstantZoneHolder.getInstance().getInstantZone(Rnd.get(609, 612));

	public FightClubArena(Player player1, Player player2, int itemId, int itemCount, Reflection reflection)
	{
		//Подключаем листенеры персонажа
		CharListenerList.addGlobal(this);

		//Инициализируем переменные класса
		_player1 = player1;
		_player2 = player2;
		_itemId = itemId;
		_itemCount = itemCount;
		_reflection = reflection;

		_reflection.init(_instantZone);

		//Инициализируем сражение
		initBattle();
	}

	/**
	 * Вызывается при выходе игрока
	 */
	@Override
	public void onPlayerExit(Player player)
	{
		if((player.getStoredId() == _player1.getStoredId() || player.getStoredId() == _player2.getStoredId()) && !_isEnded)
		{
			stopEndTask();
			setLoose((Player) player);
		}
	}

	/**
	 * Вызывается при смерти игрока
	 */
	@Override
	public void onDeath(Creature actor, Creature killer)
	{
		if((actor.getStoredId() == _player1.getStoredId() || actor.getStoredId() == _player2.getStoredId()) && !_isEnded)
		{
			stopEndTask();
			setLoose((Player) actor);
		}
	}

	private void stopEndTask()
	{
		_endTask.cancel(false);
		_endTask = ThreadPoolManager.getInstance().schedule(new EndTask(), 3000);
	}

	/**
	 * Запускает таймеры боя
	 */
	private void initBattle()
	{
		final Object[] args = { _player1, _player2, _reflection };
		_startTask = ThreadPoolManager.getInstance().scheduleAtFixedDelay(new StartTask(_player1, _player2), Config.ARENA_TELEPORT_DELAY * 1000, 1000);
		_endTask = ThreadPoolManager.getInstance().schedule(new EndTask(), ((Config.ARENA_TELEPORT_DELAY + Config.FIGHT_TIME)) * 1000);
		sayToPlayers("scripts.events.fightclub.TeleportThrough", Config.ARENA_TELEPORT_DELAY, false, _player1, _player2);
		executeTask(CLASS_NAME, "resurrectPlayers", args, Config.ARENA_TELEPORT_DELAY * 1000 - 600);
		executeTask(CLASS_NAME, "healPlayers", args, Config.ARENA_TELEPORT_DELAY * 1000 - 500);
		executeTask(CLASS_NAME, "teleportPlayersToColliseum", args, Config.ARENA_TELEPORT_DELAY * 1000);
	}

	/**
	 * Удаляет ауру у игроков
	 */
	private void removeAura()
	{
		_player1.setTeam(TeamType.NONE);
		_player2.setTeam(TeamType.NONE);
	}

	/**
	 * Выдаёт награду
	 */
	private void giveReward(Player player)
	{
		final String name = ItemFunctions.createItem(_itemId).getTemplate().getName();
		sayToPlayer(player, "scripts.events.fightclub.YouWin", false, _itemCount * 2, name);
		addItem(player, _itemId, _itemCount * 2);
	}

	private static String getItemName()
	{
		final String name = ItemFunctions.createItem(_itemId).getTemplate().getName();
		return name;
	}

	private static int getItemCount()
	{
		return _itemCount;
	}
	
	/**
	 * Выводит скорбящее сообщение проигравшему ;)
	 * @param player
	 */
	private void setLoose(Player player)
	{
		if(player.getStoredId() == _player1.getStoredId())
			giveReward(_player2);
		else if(player.getStoredId() == _player2.getStoredId())
			giveReward(_player1);
		_player1.unsetVar("FightClubRate");
		_player2.unsetVar("FightClubRate");
		_isEnded = true;
		sayToPlayer(player, "scripts.events.fightclub.YouLoose", false, new Object[0]);
	}

	/**
	 * Метод, вызываемый при ничьей. Рассчитывает победителя или объявлет ничью.
	 */
	private void draw()
	{
		if(!Config.ALLOW_DRAW && _player1.getCurrentCp() != _player1.getMaxCp() || _player2.getCurrentCp() != _player2.getMaxCp() || _player1.getCurrentHp() != _player1.getMaxHp() || _player2.getCurrentHp() != _player2.getMaxHp())
		{
			if(_player1.getCurrentHp() != _player1.getMaxHp() || _player2.getCurrentHp() != _player2.getMaxHp())
			{
				if(_player1.getMaxHp() / _player1.getCurrentHp() > _player2.getMaxHp() / _player2.getCurrentHp())
				{
					giveReward(_player1);
					setLoose(_player2);
					return;
				}
				else
				{
					giveReward(_player2);
					setLoose(_player1);
					return;
				}
			}
			else
			{
				if(_player1.getMaxCp() / _player1.getCurrentCp() > _player2.getMaxCp() / _player2.getCurrentCp())
				{
					giveReward(_player1);
					setLoose(_player2);
					return;
				}
				else
				{
					giveReward(_player2);
					setLoose(_player1);
					return;
				}
			}

		}
		sayToPlayers("scripts.events.fightclub.Draw", true, _player1, _player2);
		addItem(_player1, _itemId, _itemCount);
		addItem(_player2, _itemId, _itemCount);
	}

	/**
	 * Возващает ссылку на первого игрока
	 * @return - ссылка на игрока
	 */
	protected Player getPlayer1()
	{
		return _player1;
	}

	/**
	 * Возващает ссылку на второго игрока
	 * @return - ссылка на игрока
	 */
	protected Player getPlayer2()
	{
		return _player2;
	}

	/**
	 * Возвращает отражение
	 * @return - reflection
	 */
	protected Reflection getReflection()
	{
		return _reflection;
	}

	/**
	 * Вызывает метод суперкласса, удаляющий рефлекшен
	 * @param arena - ссылка на арену
	 */
	private void delete(long delay)
	{
		final FightClubArena[] arg = { this };
		executeTask(CLASS_NAME, "deleteArena", arg, delay);
	}

	protected static class StartTask extends RunnableImpl
	{

		private Player _player1;
		private Player _player2;
		private int _second;

		public StartTask(Player player1, Player player2)
		{
			_player1 = player1;
			_player2 = player2;
			_second = Config.TIME_TO_PREPARATION;
		}

		@Override
		public void runImpl() throws Exception
		{
			addBuffers();
			switch(_second)
			{
				case 60:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 30:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 20:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 10:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 5:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 3:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 2:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 1:
					sayToPlayers("scripts.events.fightclub.TimeToStart", _second, false, _player1, _player2);
					break;
				case 0:
					openDoors();
					deleteBuffers();
					startBattle(_player1, _player2);
					_startTask.cancel(true);
					_startTask = null;
					if(Config.FIGHT_CLUB_ANNOUNCE_START_TO_SCREEN)
						sayStartToAllPlayers("scripts.events.fightclub.AnnounceStartBatle", _player1, _player2, getItemName(), getItemCount(), false);
			}
			_second -= 1;
		}
	}

	private static String getBufferSpawnGroup(int instancedZoneId)
	{
		String bufferGroup = null;
		switch(instancedZoneId)
		{
			case 147:
				bufferGroup = "olympiad_147_buffers";
				break;
			case 148:
				bufferGroup = "olympiad_148_buffers";
				break;
			case 149:
				bufferGroup = "olympiad_149_buffers";
				break;
			case 150:
				bufferGroup = "olympiad_150_buffers";
				break;
		}
		return bufferGroup;
	}

	private static void addBuffers()
	{
		if(getBufferSpawnGroup(_reflection.getInstancedZoneId()) != null)
			_reflection.spawnByGroup(getBufferSpawnGroup(_reflection.getInstancedZoneId()));
	}

	private static void deleteBuffers()
	{
		_reflection.despawnByGroup(getBufferSpawnGroup(_reflection.getInstancedZoneId()));
	}
	
	private class EndTask extends RunnableImpl
	{
		private final Object[] args = { _player1, _player2, new Object[0] };

		@Override
		public void runImpl() throws Exception
		{
			removeAura();
			if(!_isEnded)
			{
				draw();
				_isEnded = true;
				stopEndTask();
			}
			sayToPlayers("scripts.events.fightclub.TeleportBack", Config.TIME_TELEPORT_BACK, false, _player1, _player2);
			executeTask(CLASS_NAME, "resurrectPlayers", args, Config.TIME_TELEPORT_BACK * 1000 - 300);
			executeTask(CLASS_NAME, "healPlayers", args, Config.TIME_TELEPORT_BACK * 1000 - 200);
			executeTask(CLASS_NAME, "teleportPlayersBack", args, Config.TIME_TELEPORT_BACK * 1000);
			delete((Config.TIME_TELEPORT_BACK + 10) * 1000);
		}

	}

	public static void openDoors()
	{
		for(DoorInstance door : _reflection.getDoors())
			door.openMe();
	}

	public FightClubArena()
	{}

	@Override
	public void onLoad()
	{}

	@Override
	public void onReload()
	{}

	@Override
	public void onShutdown()
	{}
}

Thanks.

Edited by r2r2
  • 0
Posted

try to add a check 

private static void deleteBuffers()
	{
	+ if(getBufferSpawnGroup(_reflection.getInstancedZoneId()) != null)
		_reflection.despawnByGroup(getBufferSpawnGroup(_reflection.getInstancedZoneId()));
	}
Guest
This topic is now closed to further replies.


  • Posts

    • ElmoreLab Harbor - Eternal C1 x1: ✅ https://harbor.elmorelab.com ElmoreLab Harbor - Eternal C1 x1 - is an exclusive server of the Eternal C1 chronicles from the top project ElmoreLab Harbor.   A unique server of its kind, on which everyone will have maximum pleasure, such as oldschool players who dream of nostalgia and to feel the warmest and classic C1 chronicles, as well as experienced players who are tired of thousands unbalanced servers of late chronicles. Due to the professional corrections of the balance system and the HONEST gameplay system - on this server, EVERY player will feel like in their own, warm and cozy Harbor C1. Let's return to the origins of L2 - back to 2004 in C1! ❤️   ⭐ Server characteristics:   STRICTLY 1 window, NO BOXES Bans for RMT and bots/cheats No donations with benefits Unique and high-quality PTS-build from Master Toma Professional corrections and full class-balance Reworked economy and closed all abuses Improved animations and all aspects of the game Exclusive HD-client with high-quality textures Experienced administration and management Fixed all bugs, geodata, exploits and holes Maximum sociality due to the 1-box system Discovering, exploring and researching Big online International server Nostalgia and oldschool-feelings   Rates: x1 Server start: 14.02.2025   The server is at the final stages of development and preparation for release. Information on the server will be updated, soon the patchnotes and changes/edits will be posted. Don't miss the legendary and epic experience on the best server in the last 20 years! ❤️ Join our C1-forum with a lot of information about server and active discussions.   ⭐ Website: https://harbor.elmorelab.com   ✅ Forum: https://forum-harbor.elmorelab.com   💥 Telegram: https://t.me/l2harbor https://t.me/l2harbor_chat   ⚡ Discord: https://discord.gg/harborelmorelab
    • yeah ok, if you say what is fuctional 100% i can't say something different 😛  but if someone find hard to compile it or get vs and all that things i have here one more simple way here to put overlay in your own server or to change your window name with few money.
    • I've been using this for 2 years now with no issues from Discord. I don't use ogg.dll either. This one works with any l2.exe too; I don’t see any difference between them.
    • hmm.. ok i just see that, is different code first of all. My sources is totally different based in other way, with else libraries.  I have access to modify everything even to make the clock to stop show how many time users play in server. 1) so maybe keep some personal info more hide. 2) i dont use ogg.dll 3) i create it and give it ready + support to install it. Plus what is mine can working with what ever .exe you want not just l2 with same simple method. And i am sure if you try this source to compile it, after 3 hours discord will like shadowban your API too thats my source
  • Topics

×
×
  • Create New...