Jump to content

Recommended Posts

Posted (edited)
### Eclipse Workspace Patch 1.0
#P L2J_DataPack
Index: dist/game/data/scripts/custom/QuizEvent/QuizEvent.java
===================================================================
--- dist/game/data/scripts/custom/QuizEvent/QuizEvent.java    (revision 0)
+++ dist/game/data/scripts/custom/QuizEvent/QuizEvent.java    (working copy)

package custom.QuizEvent;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.util.Broadcast;
import com.l2jserver.util.Rnd;

/**
 * 
 * @author Bellatrix
 *
 */
public class QuizEvent
{
    public static boolean                             _quizRunning;
    private static String                             _question;
    private static String                             _answer1;
    private static String                             _answer2;
    private static String                             _answer3;
    private static int                                 _rightanswer;
    private static Map<L2PcInstance,Integer>     _players;
    private static int                                 status;
    private static int                                 announced;
    private static ThreadPoolManager                 tpm;
    private static AutoEventTask                    task;
    private static String[][]                         _questions;
    private static int i = 0;
    private static final int STATUS_NOT_IN_PROGRESS = 0;
    private static final int STATUS_ASK = 1;
    private static final int STATUS_ANSWER = 2;
    private static final int STATUS_END = 3;
    
    //----------------------------------------------------------------------------
    //------------------------------ CONFIG --------------------------------------
    //----------------------------------------------------------------------------
    
    //Number of questions per event
    private static int _questionNumber = 3;
    
    //The Item ID of the reward
    private static int _rewardID = 57;
    
    //The ammount of the reward
    private static int _rewardCount = 1000;
    
    //Wait for the first event after the server start (in seconds)
    private static int _initWait = 3600;
    
    //Time for answer the question (in seconds)
    private static int _answerTime = 60;
    
    //Time between two event (in seconds)
    private static int _betweenTime = 18000;
    
    
    
    public QuizEvent()
    {
        tpm = ThreadPoolManager.getInstance();
        status = STATUS_NOT_IN_PROGRESS;
        task = new AutoEventTask();
        announced = 0;
        _quizRunning = false;
        _question = "";
        _answer1 = "";
        _answer2 = "";
        _answer3 = "";
        _rightanswer = 0;
        _players = new HashMap<>(100);
        _questions = new String[20][];
        includeQuestions();
        tpm.scheduleGeneral(task, _initWait*1000);
        
    }
            
    
    
    private void includeQuestions()
    {
        
        
        File questionFile = new File(Config.DATAPACK_ROOT, "data/scripts/custom/QuizEvent/QuizEvent.xml");
        Document doc = null;
        try
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setIgnoringComments(true);
            dbf.setValidating(false);
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(questionFile);
            
            for (Node root = doc.getFirstChild(); root != null; root = root.getNextSibling())
            {
                if ("list".equalsIgnoreCase(root.getNodeName()))
                {
                    
                    for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling())
                    {
                
                        if ("question".equalsIgnoreCase(child.getNodeName()))
                        {
                            int id, correct;
                            String ask, answer1, answer2, answer3;
                            NamedNodeMap attrs = child.getAttributes();
                            
                            id = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
                            correct = Integer.parseInt(attrs.getNamedItem("correct").getNodeValue());
                            ask = attrs.getNamedItem("ask").getNodeValue();
                            answer1 = attrs.getNamedItem("answer1").getNodeValue();
                            answer2 = attrs.getNamedItem("answer2").getNodeValue();
                            answer3 = attrs.getNamedItem("answer3").getNodeValue();
                            
                            _questions[id] = new String[]{ ask, answer1, answer2, answer3, ""+correct }; 
                            i++;
                        
                            
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            
        }
    }
    
    
    
    
    
    
    private class AutoEventTask implements Runnable
    {
        @Override
        public void run()
        {
            switch (status)
            {
            case STATUS_NOT_IN_PROGRESS:
                announceStart();
                break;
            case STATUS_ASK:    
                    if (announced < _questionNumber)
                    {
                    announceQuestion();
                    }
                    else
                    {
                    status = STATUS_END;
                    tpm.scheduleGeneral(task, 3000);
                    }
                break;
            case STATUS_ANSWER:
                announceCorrect();
                break;
            case STATUS_END:
                endEvent();
                break;
            default:
                break;
                
            }
        }
    }
    
    
    
    //Get a random question from the quiz_event table    
    private static void selectQuestion()
    {
        int id = Rnd.get(i)+1;
        _question = _questions[id][0];        
        _answer1 = _questions[id][1];
        _answer2 = _questions[id][2];
        _answer3 = _questions[id][3];
        _rightanswer = Integer.parseInt(""+_questions[id][4]);
    }
    
    
    
    //Announce the question
    private static void announceQuestion()
    {

        selectQuestion();
        Broadcast.toAllOnlinePlayers("-----------------");
        Broadcast.toAllOnlinePlayers("Question: "+_question);
        Broadcast.toAllOnlinePlayers("-----------------");
        Broadcast.toAllOnlinePlayers("1: "+_answer1);
        Broadcast.toAllOnlinePlayers("2: "+_answer2);
        Broadcast.toAllOnlinePlayers("3: "+_answer3);
        Broadcast.toAllOnlinePlayers("-----------------");
        
        status = STATUS_ANSWER;
        tpm.scheduleGeneral(task, _answerTime*1000);
    }
    
    
    
    //Announce the correct answer
    private static void announceCorrect()
    {
        Broadcast.toAllOnlinePlayers("-----------------");
        Broadcast.toAllOnlinePlayers("The correct answer was: "+_rightanswer);
        Broadcast.toAllOnlinePlayers("-----------------");
        announced++;
        giveReward();
        status = STATUS_ASK;
        tpm.scheduleGeneral(task, 5000);
    }
    
    
    private static void announceStart()
    {
        _quizRunning = true;
        _players.clear();
        Broadcast.toAllOnlinePlayers("Quiz Event begins! "+_questionNumber+" questions. "+_answerTime+" secs for answer each. ");
        Broadcast.toAllOnlinePlayers("Type . and the number of the correct answer to the chat. (Like: .1)");
        Broadcast.toAllOnlinePlayers("Get Ready!");
                
        status = STATUS_ASK;
        tpm.scheduleGeneral(task, 5000);
    }
    
    //Add a player and its answer
    public static void setAnswer(L2PcInstance player, int answer)
    {
        if( _players.containsKey(player) )
            player.sendMessage("You already choosen an aswer!: "+_players.get(player));
        else
        _players.put(player, answer);
    }
    
    
    private static void endEvent()
    {
        _quizRunning = false;
        Broadcast.toAllOnlinePlayers("The Quiz Event is over!");
        announced = 0;
        status = STATUS_NOT_IN_PROGRESS;
        tpm.scheduleGeneral(task, _betweenTime*1000);
    }
    
    
    
    private static void giveReward()
    {        
        for( L2PcInstance p: _players.keySet())
        {
            if(_players.get(p) == _rightanswer)
                {
                p.sendMessage("Your answer was correct!");
                p.addItem("Quiz", _rewardID, _rewardCount, p, true);
                }
                else
                {
                p.sendMessage("Your answer was not correct!");
                }

            
        }
        _players.clear();
    }
}
\ No newline at end of file
Index: dist/game/data/scripts/Custom/QuizEvent/QuizEvent.xml
===================================================================
--- dist/game/data/scripts/custom/QuizEvent/QuizEvent.xml    (revision 8768)
+++ dist/game/data/scripts/custom/QuizEvent/QuizEvent.xml    (working copy)
<?xml version="1.0" encoding="UTF-8"?>
<list>
    <question id = "1" ask = "Quel type Bijoux Drop Baium" answer1 = "Necklace" answer2 = "Ring" answer3 = "Earring" correct = "2" />
    <question id = "2" ask = "Comment s'appel l'admin" answer1 = "Bellatrix" answer2 = "Roberta" answer3 = "Jo" correct = "1" />
    <question id = "3" ask = "Quel Recompense donne le tvt" answer1 = "Codex" answer2 = "Coin" answer3 = "EventCoin" correct = "3" />
</list>
Index: dist/game/data/scripts/handlers/voicedcommandhandlers/Quiz.java
===================================================================
--- dist/game/data/scripts/handlers/voicedcommandhandlers/Quiz.java    (revision 0)
+++ dist/game/data/scripts/handlers/voicedcommandhandlers/Quiz.java    (working copy)
package handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

import custom.QuizEvent.QuizEvent;

/**
 * @author Bellatrix
 */
public class Quiz implements IVoicedCommandHandler {
    private static final String[] _voicedCommands = {
        "quiz",
        "1",
        "2",
        "3"
    };
    
    /**
     * @see Bellatrix
     */
    @Override
    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
        
        if (command.equalsIgnoreCase("1") && QuizEvent._quizRunning) {
            QuizEvent.setAnswer(activeChar, 1);
        }
        
        if (command.equalsIgnoreCase("2") && QuizEvent._quizRunning) {
            QuizEvent.setAnswer(activeChar, 2);
        }
        
        if (command.equalsIgnoreCase("3") && QuizEvent._quizRunning) {
            QuizEvent.setAnswer(activeChar, 3);
        }
        return true;
    }
    
    /**
     * @see Bellatrix
     */
    @Override
    public String[] getVoicedCommandList() {
        new QuizEvent();
        return _voicedCommands;
    }
}
Index: dist/game/data/scripts/handlers/MasterHandlers.java
===================================================================
--- dist/game/data/scripts/handlers/MasterHandlerjava    (revision 0)
+++ dist/game/data/scripts/handlers/Masterhandlers.java    (working copy)
import handlers.voicedcommandhandlers.Quiz;


    private static final Class<?>[] VOICED_COMMAND_HANDLERS =
    {
        StatsVCmd.class,
        // TODO: Add configuration options for this voiced commands:
        // CastleVCmd.class,
        // SetVCmd.class,
        (Config.L2JMOD_ALLOW_WEDDING ? Wedding.class : null),
        (Config.BANKING_SYSTEM_ENABLED ? Banking.class : null),
        (Config.L2JMOD_CHAT_ADMIN ? ChatAdmin.class : null),
        (Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
        (Config.L2JMOD_ENABLE_ONLINE_STATUS ? OnlineStatus.class : null),
        (Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
        (Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
        Quiz.class,

 

Edited by extasie80
  • Like 1
  • Upvote 1
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • IOThread [3][47] (good) good IOThread [3][47] (good) good IOThread [3][47] (good) good     IOThread [6][78] (ahehe): ahehe
    • rly swired...leave low npcmakers ,its worked..not crash L2server.exe.   A:I:S:E:PE:DI:DE:BO=1.000000:1.000000:1.000000:1.000000:1.000000:0:0:0 L:Y:X:H=0:0:0:0:0 Crashed Thread[6]. Server Up Time : Wed Oct 15 13:11:08 2025 Current Time : Wed Oct 15 13:13:35 2025 Elapsed Time : 0 days 0 hours 2 minutes 27 seconds IOBufferPool - 39989 / 40000, PendingWrite 0 bytes [0] =============== object report user[0/0], npc[820/0], item[0/0], usersocket[0] =============== npc server connection log Connect : Wed Oct 15 13:13:34 2025 [(16328) 2025/10/15 13:13:35]: ======================= an Access Violation in module L2Server.exe at 0033:00518eef. start at 2025/10/15 13:11:08 Read from location ffffffff caused an access violation. Registers: EAX=0003dc7b CS=0033 EIP=00518eef EFLGS=00010207 EBX=a2228c44 SS=002b ESP=7da7f870 EBP=00000000 ECX=0003dc7b DS=002b ESI=00000000 FS=0053 EDX=00400000 ES=002b EDI=0c200dc0 GS=002b Bytes at CS:EIP: 48 8b 0c f0 80 79 5d 00 74 23 44 39 69 10 7f 1d Stack dump: 7da7f870: a2228c44 00000000 0004c158 00000000 009b2a10 00000000 00400000 00000000 7da7f890: 00000001 00000000 00000000 00000000 fffffffe ffffffff 00000000 40cae180 7da7f8b0: 00000000 40d11740 00000000 c0b1be00 00000000 00000000 00000000 00000000 7da7f8d0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 7da7f8f0: 3b19e2dc 00000000 0078e4c8 00000000 3b19e2dc 00000000 00400000 00000000 7da7f910: 0004c158 00000000 00000000 00000000 00000000 00000000 006c688a 00000000 7da7f930: a2228c44 00000000 00000000 00000000 00000000 00000000 00a2aa10 00000000 7da7f950: 012e6dc0 00000000 9beaee10 00000000 00000000 00000000 0004c158 00000000 7da7f970: 00000000 00000000 00a12d50 00000000 fffffffe ffffffff 0064dd24 00000000 7da7f990: fffffffe ffffffff 00000000 00000000 00000000 00000000 00000000 00000000 ver = Dec 16 2005_22:03:13 GuardInfo : IOThread [0][63] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) Lock Stack : IOThread [1][63] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) Lock Stack : IOThread [2][78] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) Lock Stack : IOThread [3][47] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) Lock Stack : IOThread [4][78] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) Lock Stack : IOThread [5][78] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) Lock Stack : IOThread [6][78] (ahehe): void IOThread_common(void *arglist) -> void CIOObject::TimerDispatch(bool bRootLoop) -> void CThreadLocalTimer::Dispath -> void CEnterWorldSerializer::TimerExpired(int id) -> void CNPC::EnterWorld(bool bSetDefaultParam, int nHP, int nMP) -> CCreature::EnterWorld Lock Stack : .\NpcSocket.cpp(278[116]) IOThread [7][78] (good): void IOThread_common(void *arglist) -> bool NpcEnterWorldPacket(NpcSocket* pSocket, const unsigned char *pPacket) -> void Push(int index, int x, int y, int z, int dir, int nSetDefaultParam, int nHP, int nMP) Lock Stack : .\NpcSocket.cpp(389[185]) ListenThread [13][141] (good): void ListenThread_common() -> unsigned __stdcall WaitThread(void *) Lock Stack : MainThread [12][156] (good): Lock Stack : GuardInfo end [(16328) 2025/10/15 13:13:35]: *.\ioc.cpp:648(Tue Dec 13 02:52:40 2005) exception  
    • We can help your Telegram channel, group, bot, or account appear first in Telegram search.   Our safe Telegram SEO service helps you rank your Telegram channel or bot for any keyword in just 72 hours.   No spam, no fake traffic — only real Telegram keyword ranking using premium user signals and smart optimization.   ✅ What We Offer • Top 1 Telegram Search Ranking Service (Channels · Groups · Bots · Accounts) • Rank Telegram channel, group, or bot safely with real engagement • Appear first in Telegram search for your target keyword • Pay-per-keyword with refund-backed guarantee • Global targeting (USA, EU, India)   🧩 Works Best For • Projects that need to appear first in Telegram search • Brands, crypto/NFT groups, trading or SaaS communities • Bot owners who want ranked visibility for their bot • Channels and groups needing more exposure   💡 Why Choose Us   We use safe Telegram SEO techniques — not spam — to deliver fast, stable Telegram top search results.   Our process helps your project gain organic visibility and steady traffic from real Telegram users.   📩 To Get More Information   Telegram: @TeleLoopPulse   Website : https://telegramgrowthstudio.com/telegram-search-ranking.html
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock