Thread: Insanityx 317Pi Base Trivia bot help

Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16
  1. #11  
    Registered MrClassic
    MrClassic's Avatar
    Join Date
    Oct 2008
    Age
    15
    Posts
    2,063
    Thanks given
    24,154
    Thanks received
    551
    Rep Power
    5000
    here you go fixed and looks much better

    Code:
    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?", "InsidiaX"},
    		{"<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;
    }
    Quote Originally Posted by Jrage View Post
    New errors, Im stuck and so tired, gonna post them, head to bed, wake up, try to fix, if I cant I'll look here. lol

    Code:
    src\server\model\players\packets\Commands.java:14: error: cannot find symbol
    import server.model.players.TriviaBot;
                               ^
      symbol:   class TriviaBot
      location: package server.model.players
    src\server\Server.java:20: error: cannot find symbol
    import server.model.players.TriviaBot;
                               ^
      symbol:   class TriviaBot
      location: package server.model.players
    src\server\model\players\packets\Commands.java:143: error: cannot find symbol
    if(TriviaBot.acceptingQuestion()){
       ^
      symbol:   variable TriviaBot
      location: class Commands
    src\server\model\players\packets\Commands.java:144: error: cannot find symbol
    TriviaBot.attemptAnswer(c, triviaAnswer);
    ^
      symbol:   variable TriviaBot
      location: class Commands
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    4 errors
    Press any key to continue . . .
    the import you need is:
    Code:
    import server.model.minigames.TriviaBot;
    just replace it
    Reply With Quote  
     

  2. #12  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    I moved things around and forgot to fix the package.....
    Reply With Quote  
     

  3. Thankful user:


  4. #13  
    Registered MrClassic
    MrClassic's Avatar
    Join Date
    Oct 2008
    Age
    15
    Posts
    2,063
    Thanks given
    24,154
    Thanks received
    551
    Rep Power
    5000
    Quote Originally Posted by Jrage View Post
    I moved things around and forgot to fix the package.....
    You fixed it?
    Reply With Quote  
     

  5. #14  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    Yes Thanks, I told you, been at it too long, need to go to sleep..... lmfao

    Code:
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Press any key to continue . . .
    Reply With Quote  
     

  6. #15  
    Registered MrClassic
    MrClassic's Avatar
    Join Date
    Oct 2008
    Age
    15
    Posts
    2,063
    Thanks given
    24,154
    Thanks received
    551
    Rep Power
    5000
    Quote Originally Posted by Jrage View Post
    Yes Thanks, I told you, been at it too long, need to go to sleep..... lmfao

    Code:
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Press any key to continue . . .
    nice use an IDE btw.

    It will be much better to see errors. There are plenty of eclipse or intelliJ tutorials on this forums (both IDE's)
    Reply With Quote  
     

  7. #16  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    Quote Originally Posted by MrClassic View Post
    nice use an IDE btw.

    It will be much better to see errors. There are plenty of eclipse or intelliJ tutorials on this forums (both IDE's)
    Gonna talk to you in the chatbox, easier.
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Trivia bot help (commands)
    By azzacustoms in forum Help
    Replies: 7
    Last Post: 10-14-2015, 08:03 AM
  2. [677+] Trivia Bot Help
    By Guru. in forum Help
    Replies: 11
    Last Post: 05-10-2014, 05:03 AM
  3. Trivia bot help.
    By always in forum Help
    Replies: 23
    Last Post: 12-22-2012, 04:11 AM
  4. trivia bot help
    By getsuga121 in forum Help
    Replies: 4
    Last Post: 08-14-2012, 04:29 AM
  5. trivia bot help
    By getsuga121 in forum Help
    Replies: 2
    Last Post: 08-14-2012, 12:42 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •