Noticias:

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

Menú Principal

Evento Preguntas

Iniciado por Swarlog, Ago 06, 2022, 02:30 AM

Tema anterior - Siguiente tema

Swarlog

Evento para L2jserver H5

Cada 1 hora comienza el evento, se anuncia una pregunta, el que player que conteste correctamente por shout se le dara el reward y finalizara el evento. Es recomendable que el shout sea global


como configurarlo
indicar el tiempo de ciclo del evento en minutos
// indicar el tiempo de ciclo del evento en minutos
private final int ciclo = 60;
indicar el numero de preguntas
// indica el numero de preguntas
private final int random = 2;

indicar las preguntas y respuestas siguiendo su orden
private final String[] preguntas =
{
"Cual es la clase mago que tiene la skill empowering echo?",
"Como le dicen a un noob en Latinoamerica?"
};
private final String[] respuestas =
{
"spellhowler",
"pete"
};
indicar la id de los items y la cantidad de reward
private final int[][] items =
{
{
6392,
1
},
{
6393,
1
}
};

crear una carpeta en scripts/custom llamada Preguntas y guardar el script en Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate
activar en scripts.cfg

/*
 * Copyright (C) 2004-2015 L2J DataPack
 *
 * This file is part of L2J DataPack.
 *
 * L2J DataPack 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.
 *
 * L2J DataPack 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 custom.Preguntas;

import java.util.ArrayList;

import ai.npc.AbstractNpcAI;

import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.events.EventType;
import com.l2jserver.gameserver.model.events.ListenerRegisterType;
import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
import com.l2jserver.gameserver.model.events.annotations.RegisterType;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerChat;
import com.l2jserver.gameserver.util.Broadcast;
import com.l2jserver.util.Rnd;

/**
 * @author Eze
 */
public class Preguntas extends AbstractNpcAI
{
private boolean started = false;
// indicar el tiempo de ciclo del evento en minutos
private final int ciclo = 60;
// indica el numero de preguntas
private final int random = 2;
private int num;
private final ArrayList<L2PcInstance> ganadores = new ArrayList<>();
// indicar las preguntas
private final String[] preguntas =
{
"Cual es la clase mago que tiene la skill empowering echo?",
"Como le dicen a un noob en Latinoamerica?"
};
private final String[] respuestas =
{
"spellhowler",
"pete"
};
// indicar la id de los items y la cantidad de reward
private final int[][] items =
{
{
6392,
1
},
{
6393,
1
}
};

private Preguntas()
{
super(Preguntas.class.getSimpleName(), "custom");

startQuestTimer("pregunta", 1 * 60000, null, null);
}

@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equals("pregunta"))
{
ganadores.clear();
num = Rnd.get(random);
Broadcast.announceToOnlinePlayers("Evento de Preguntas. El que conteste la respuesta correcta en minusculas por Shout se le entregara un reward :", false);
Broadcast.announceToOnlinePlayers(preguntas[num], true);
started = true;
}
else if (event.equals("finalizo"))
{
Broadcast.announceToOnlinePlayers("El ganador es " + ganadores.get(0).getName() + ". Proximo evento en 1 Hora", false);
for (int[] itemId : items)
{
ganadores.get(0).addItem("ganador", itemId[0], itemId[1], null, true);
}
startQuestTimer("pregunta", ciclo * 60000, null, null);
}

return super.onAdvEvent(event, npc, player);
}

@RegisterEvent(EventType.ON_PLAYER_CHAT)
@RegisterType(ListenerRegisterType.GLOBAL)
public void Chat(OnPlayerChat event)
{

if ((!started) || (started && (event.getChatType() != 1)))
{
return;
}
if (!event.getText().equals(respuestas[num]))
{
return;
}
ganadores.add(event.getActiveChar());
started = false;
startQuestTimer("finalizo", 1 * 1000, null, null);
}

public static void main(String[] args)
{
new Preguntas();
}
}

creditos = execanciani