Tópico: [L2JServer] CTF Mod -
Ver um Único Post
Antigo 17-02-2010, 10:45 PM   #15 (permalink)
xxxvalterxxx
Amigo SE
 
Avatar de xxxvalterxxx
 
Registrado em: Dec 2008
Localização: Um lugar onde vc não sabe onde é.
Posts: 400
Agradeceu: 201
Agradecido 444 Vezes em 128 Posts
Achei Ruim:
Acharam ruim Vezes em Posts

Inventório de xxxvalterxxx

Padrão

filipephp, se estiver usando L2JServer, scripts/handlers será sua resposta
Crie um txt e renomeie para CTFCmd.java (a extenção é java), e salve isto nele:

Código: [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
/*
 * 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 handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.CTF;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;

public class CTFCmd implements IVoicedCommandHandler
{
	private static final String[] VOICED_COMMANDS = { "joinctf", "leavectf", "infoctf" };

	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
	{
		if (command.startsWith("joinctf"))
		{
			JoinCTF(activeChar);
		}
		else if(command.startsWith("leavectf"))
		{
			LeaveCTF(activeChar);
		}

		else if(command.startsWith("infoctf"))
		{
			SendCTFinfo(activeChar);
		}

		return true;
	}

	public String[] getVoicedCommandList()
	{
		return VOICED_COMMANDS;
	}

	public boolean JoinCTF (L2PcInstance activeChar)
	{
		if ( activeChar == null)
		{
			return false;
		}
		NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage( 0 );

		
		if (!CTF._joining) //check if ctf event is running or/and joining is avaliable
		{
			npcHtmlMessage.setHtml("<html><body>You can not register now: CTF event joining is not avaliable.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if (activeChar._inEventCTF) //check if player is already registered in ctf event
		{
			npcHtmlMessage.setHtml("<html><body>You are participating this event already.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if ( activeChar.isCursedWeaponEquipped()) //check if player is holding a cursed weapon
		{
			npcHtmlMessage.setHtml("<html><body>You are not allowed to participate to the Event holding a Cursed Weapon.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if ( activeChar.isInOlympiadMode()) //check if player is in olympiads - dunno why, but sometimes simple doesnt work this check =/
		{
			npcHtmlMessage.setHtml("<html><body>You are not allowed to participate to the Event while in Olympiad.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if (activeChar.isInJail()) //check if player is in jail
		{
			npcHtmlMessage.setHtml("<html><body>You are not allowed to participate to the Event while in Jail.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if (activeChar.getLevel() < CTF._minlvl)
		{
			npcHtmlMessage.setHtml("<html><body>Your level is too low to participate at this Event.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if (activeChar.getKarma() > 0) //check player  karma - dunno why karma players cant participate - looks useless since player can register while not with karma and do pk after that ;)
		{
			npcHtmlMessage.setHtml("<html><body>You are not allowed to participate to the Event with Karma.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if (CTF._maxPlayers == CTF._playersShuffle.size()) //check player  karma - dunno why karma players cant participate - looks useless since player can register while not with karma and do pk after that ;)
		{
			npcHtmlMessage.setHtml("<html><body>Sorry,CTF Event is full.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else //send dialog confirmation to  player that he is registered in ctf event and add him
		{
			npcHtmlMessage.setHtml("<html><body>Your participation in the CTF event has been aproved.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			CTF.addPlayer(activeChar,"");
			return true;
		}
	}

	public boolean LeaveCTF (L2PcInstance activeChar)
	{
		if ( activeChar == null)
		{
			return false;
		}
	
		NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage( 0 );

		if (!CTF._joining) //check if CTF event is running or joining is avaliable
		{
			npcHtmlMessage.setHtml("<html><body>You can not unregister now cause there is no CTF event running.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else if (CTF._teleport || CTF._started) //check if ctf event has already teleported and started
		{
			npcHtmlMessage.setHtml("<html><body>You can not leave after CTF event has started.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
		else //send dialog confirmation to  player that he is unregistered from ctf event and remove him
		{
			npcHtmlMessage.setHtml("<html><body>Your participation in the CTF event has been removed.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			CTF.removePlayer(activeChar);
			return true;
		}
	}
	public boolean SendCTFinfo (L2PcInstance activeChar)
	{
		if ( activeChar == null)
		{
			return false;
		}
		NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage( 0 );

		
		if (CTF._joining)
		{
			npcHtmlMessage.setHtml("<html><body>There are " + CTF._playersShuffle.size() + " players participating in this event.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return true;
		}
		else
		{
			npcHtmlMessage.setHtml("<html><body>There is no Event in progress.</body></html>");
			activeChar.sendPacket( npcHtmlMessage );
			return false;
		}
	}
}
Jogue o arquivo na pasta scripts/handlers/voicedcommandhandlers

No diretório acima, scripts/handers, há um arquivo chamado MasterHandler.java
Role a barra até ver a frase:
Citação:
private static void loadVoicedHandlers()
Nas linhas abaixo se você souber de java, verá que há varias importações.
Somente coloque isto abaixo ou acima de alguma (Cuidado para não danificar nada!)

Código: [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
		if (Config.CTF_ALLOW_VOICE_COMMAND)
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new CTFCmd());
Não modifiquei o código, pois estou atarefado (nem lembro como escreve)
Então crie uma pasta chamada l2jlive na sua pasta config, e crie um arquivo chamado Events.properties (Extenção .properties!)
Insira isso dentro do arquivo que você criou:

Código: [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
#--------------------------------------------------------
# Event's Settings- By L2jLive Team
#--------------------------------------------------------
# -----------------------------
# Capture The Flag - CTF
# -----------------------------
# CTFEvenTeams = NO|BALANCE|SHUFFLE
# NO means: not even teams.
# BALANCE means: Players can only join team with lowest player count.
# SHUFFLE means: Players can only participate to the event and not direct to a team. Teams will be shuffled on teams teleport.
# Default: SHUFFLE
CTFEvenTeams = SHUFFLE

# Allow voiced command on CTF Event?
# Default: False
CTFAllowVoiceCommand = False

# Players that are not participating in CTF can target ctf participants?
# Default: False
CTFAllowInterference = False

# CTF participants can use potions?
# Default: False
CTFAllowPotions = False

# CTF participants can summon by item?
# Default: False
CTFAllowSummon = False

# Remove all effects of CTF participants on event start?
# Default: True
CTFOnStartRemoveAllEffects = True

# Unsummon pet of CTF participants on event start?
# Default: True
CTFOnStartUnsummonPet = True

# On revive participants regain full HP/MP/CP?
# Default: False
CTFReviveRecovery = False

# Announce all team statistics
# Default: False
CTFAnnounceTeamStats = False

# Announce reward
# Default: False
CTFAnnounceReward = False

# Players with cursed weapon are allowed to join?
# Default: True
CTFJoinWithCursedWeapon = True

# Delay on revive when dead, NOTE: 20000 equals to 20 seconds, minimum 1000 (1 second)
# Default: 20000
CTFReviveDelay = 20000
As outras configs são irrelevantes, só é necessário por o CTFAllowVoiceCommand = True

Até mais, espero que eu tenha ajudado.

__________________
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
xxxvalterxxx está offline   Responder com Citação