Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • stCky: idk man im just a chat bot
      August 22, 2017, 11:14:52 PM
    • symantec: is this forum
      August 22, 2017, 09:02:56 PM
    • symantec: what the fudge
      August 22, 2017, 09:02:52 PM
    • symantec: I just joined to download datmaker, the links are broken and a user named i nelson i has a fudgeing weird signature
      August 22, 2017, 08:59:33 PM
    • stCky: ur so cool and edgy
      August 22, 2017, 04:15:50 PM
    • Deathspirit: anyways, i'm un ip banned now.. but don't even want to be that at this point lmfao
      August 22, 2017, 01:58:14 PM
    • Deathspirit: now it's some sell out half leeched server :')
      August 22, 2017, 01:57:53 PM
    • Deathspirit: gf moparscape, was the best rsps community i've been on since 2006
      August 22, 2017, 01:57:31 PM
    • stCky: yeah, nah. it's cooked. [link] might help u with a backup or something idk man im just a chat bot
      August 22, 2017, 12:13:25 AM
    • flew420: I sure hope someone has a copy of the forum before it was recked
      August 21, 2017, 11:40:52 PM
    • flew420: O wow i see now, just read thru all the news articles. :(  i've been out of the game for a couple years so coming back to this shit is sad.
      August 21, 2017, 11:39:46 PM
    • flew420: Huh?
      August 21, 2017, 10:49:51 PM
    • stCky: got bought by a russian dude, he put a shitty rsps on it for donations, now no one cares
      August 21, 2017, 10:48:30 PM
    • flew420: I came on for some nostalgic reading in old classic development, and it only goes back to 2014 wtf.
      August 21, 2017, 10:43:09 PM
    • flew420: what happened to this site??
      August 21, 2017, 10:42:36 PM
    • Sean56:[link]
      August 21, 2017, 05:33:45 PM
    • kb010: how can i play? i downloaded the client and it doesnt open.
      August 21, 2017, 10:52:56 AM
    • wodkode: shut it down or fix it
      August 20, 2017, 10:11:28 PM
    • wodkode: dude i cant goto no links on here from google
      August 20, 2017, 10:11:13 PM
    • Dell: Greetings
      August 20, 2017, 11:56:30 AM

    Author Topic: [PI] Fully Working Trivia Bot [RELEASE]  (Read 4529 times)

    0 Members and 1 Guest are viewing this topic.

    Offlinetribalpkz

    • First Time Poster
    • *
    • Posts: 4
    • Thanks: +0/-0
      • View Profile
    [PI] Fully Working Trivia Bot [RELEASE]
    « on: April 08, 2014, 07:08:37 PM »
    What you're adding:

    A trivia class that sends a random trivia question each time a cycle timer is sent. This is normally every 6 minutes. (This is because otherwise the server adds 1 question to the questions sent so you'll end up sending 50+ questions all in one big block)



    Difficulty: Easy 1/10
    Classes Modified: Server.java, Commands.java
    Classes Created: TriviaBot.java

    Step One: (Creating the Trivia Bot)

    Go to your Minigames Folder, normally found src/server/model/minigames

    Create a new java file, and add the following script.
    Code: [Select]
    package server.model.minigames;

    import server.event.Event;
    import server.event.EventContainer;
    import server.event.EventManager;
    import server.model.players.Player;
    import server.model.players.PlayerHandler;
    import server.util.Misc;
    import server.model.players.Client;
    public class TriviaBot {
    public static void startup() {
    EventManager.getSingleton().addEvent(new Event() {
    @Override
    public void execute(EventContainer e) {
    if (getPlayerCount() > 0) {
    askQuestion();
    }
    }
    }, 900000);
    }
    public static void attemptAnswer(Player p, String attempt) {
    if (!currentQuestion.equals("") && attempt.replaceAll("_", " ").equalsIgnoreCase(currentAnswer)) {
    currentQuestion = "";
    p.pkPoints++;
    sendServerMessage("<shad=255>Well done! "+p.playerName + " has quessed the question correctly and earned 1 Trivia Point!");
    }
    }
    public static boolean acceptingQuestion() {
    return !currentQuestion.equals("");
    }
    public static void askQuestion() {
    final int random = Misc.random(TRIVIA_DATA.length - 1);

    currentQuestion = TRIVIA_DATA[random][0];
    currentAnswer = TRIVIA_DATA[random][1];

    sendServerMessage(currentQuestion);
    }
    private static int getPlayerCount() {
    int players = 0;
    for (Player p : PlayerHandler.players) {
    if (p != null)
    players++;
    }
    return players;
    }
    private static void sendServerMessage(String message) {
    for (Player p : PlayerHandler.players) {
    if (p != null) {
    ((Client)p).sendMessage(message);
    }
    }
    }
    private static final String[][] TRIVIA_DATA = {
    {"<shad=255>[Trivia] What is the highest combat level in the game?", "126"},
    {"<shad=255>[Trivia] What is the highest leveled NPC in the game?", "Corporal Beast"},
    {"<shad=255>[Trivia] Who created the server originally?", "Owner's name here"},
    {"<shad=255>[Trivia] Which NPC sells magic gear"Zaff"},
    {"<shad=255>[Trivia] What is the highest rank in the game?", "Owner"},
    };
    private static String currentQuestion;
    private static String currentAnswer;
    }

    Step Two: (Adding a Command to Answer Questions)

    Open your Commands.java file, and add the following command for players.

    Code: [Select]
    if(playerCommand.startsWith("trivia") || playerCommand.startsWith("Trivia") || playerCommand.startsWith("TRIVIA")){
    String triviaAnswer = playerCommand.substring(7);
    if(TriviaBot.acceptingQuestion()){
    TriviaBot.attemptAnswer(c, triviaAnswer);
    }
    }

    Step Three: (Adding a script to send a question during cycle)

    Now finally, open up Server.java

    Search: "Average Cycle Time:"

    Under that, add this:

    Code: [Select]
    TriviaBot.askQuestion();

    Now Compile. The script should run successfully, should you find any errors. Post them here.

    Offlinerespectable

    • First Time Poster
    • *
    • Posts: 2
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #1 on: April 21, 2014, 05:46:04 PM »
    Looking good! Will add tomorrow!

    OfflineGfServerMaker1

    • Member
    • **
    • Posts: 53
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #2 on: May 02, 2014, 12:45:18 PM »
    [url]http://i62.tinypic.com/o7r6t3.gif[url]


    OfflineKid Murderer

    • First Time Poster
    • *
    • Posts: 1
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #3 on: May 17, 2014, 05:05:55 PM »


    import server.model.minigames.TriviaBot;

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #4 on: May 17, 2014, 05:36:21 PM »
    Use a hashmap, it is perfect for this.

    OfflineDan0194

    • Member
    • ****
    • Posts: 1,140
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #5 on: May 17, 2014, 10:16:31 PM »
    Use a hashmap, it is perfect for this.
    A string array is fine for this.
    lol who told you winterLove had bad codes
    Smart man.
    if you read this your a fagit

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #6 on: May 17, 2014, 10:30:05 PM »
    Use a hashmap, it is perfect for this.
    A string array is fine for this.
    Can't argue with that, just figured it'd be something new he could learn (if he doesn't know it already).

    Offlinejack332

    • Member
    • ***
    • Posts: 101
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Fully Working Trivia Bot [RELEASE]
    « Reply #7 on: June 17, 2014, 02:52:15 PM »
    Compiling
    src\server\model\minigames\TriviaBot.java:58: error: '}' expected
                    {"<shad=255>[Trivia] Which NPC sells magic gear"Zaff"},
                                                                    ^
    src\server\model\minigames\TriviaBot.java:58: error: unclosed string literal
                    {"<shad=255>[Trivia] Which NPC sells magic gear"Zaff"},
                                                                        ^
    src\server\model\minigames\TriviaBot.java:59: error: not a statement
                    {"<shad=255>[Trivia] What is the highest rank in the game?", "Ow
    ner"},
                     ^
    src\server\model\minigames\TriviaBot.java:59: error: ';' expected
                    {"<shad=255>[Trivia] What is the highest rank in the game?", "Ow
    ner"},
                                                                               ^
    src\server\model\minigames\TriviaBot.java:59: error: illegal start of type
                    {"<shad=255>[Trivia] What is the highest rank in the game?", "Ow
    ner"},

         ^
    src\server\model\minigames\TriviaBot.java:59: error: ';' expected
                    {"<shad=255>[Trivia] What is the highest rank in the game?", "Ow
    ner"},

          ^
    6 errors
    Press any key to continue . . .


     when i compile, any ideas?
    who the hell are u looking at, if u got ben's project source can u please send me a copy add me on skype ;) deadlysoul rsps

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal