Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Mensaje de Clan Instantaneo

Iniciado por Swarlog, Sep 01, 2022, 12:41 AM

Tema anterior - Siguiente tema

Swarlog

este codigo lo que hace es que los lideres de clanes mediande el comando ".cmessage" puedan mandar un mensaje de pantalla con duracion de 5 segundos a todos los miembros del clan. Es sencillo el codigo pero puede servir a algunos que lo necesiten.

/*
 * 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.L2ClanMember;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;

/**
 * ClanMessage (cmenssage)
 * Original Java script by Fissban.
 * @author swarlog
 */

public class ClanMessage implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"cmenssage"
};

@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
target = activeChar.getName() + ": " + target;
final ExShowScreenMessage cs = new ExShowScreenMessage(target, 5000);

if (activeChar.getClan() != null)
{
if (activeChar.isClanLeader())
{
for (L2ClanMember member : activeChar.getClan().getMembers())
{
if (member.isOnline())
{
member.getPlayerInstance().sendPacket(cs);
}
}

return true;
}

activeChar.sendMessage("Solo el lider del clan puede utilizar este comando!");
return false;
}

activeChar.sendMessage("Solo los lideres de un clan pueden utilizar este comando y tu no tienes clan!");
return false;
}

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