Thread: [FIXED]PI 317 trivia easy question

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 [FIXED]PI 317 trivia easy question 
    Donator

    Join Date
    Mar 2012
    Posts
    179
    Thanks given
    16
    Thanks received
    3
    Rep Power
    9
    okay well i want to make it so that my trivia will give you one specific item and well ive tried adding soemthing like c.getItems().addItem(995, 125000); but that jsut does not seem to work everytime my compiler ends up saying
    src\server\model\minigames\TriviaBot.java:24: error: cannot find symbol
    c.getItems().addItem(995, 125000);
    ^
    symbol: variable c
    location: class TriviaBot
    1 error

    just would like help please
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    May 2012
    Posts
    474
    Thanks given
    93
    Thanks received
    74
    Rep Power
    634
    It means you haven't declared c as a variable. I haven't looked at any PI in ages, so I'm not sure exactly what you need to do, but I have an idea. I'm going to install IntelliJ IDEA in a few and download a clean PI and play with it.
    Reply With Quote  
     

  3. #3  
    Donator

    Join Date
    Mar 2012
    Posts
    179
    Thanks given
    16
    Thanks received
    3
    Rep Power
    9
    Quote Originally Posted by Hart View Post
    It means you haven't declared c as a variable. I haven't looked at any PI in ages, so I'm not sure exactly what you need to do, but I have an idea. I'm going to install IntelliJ IDEA in a few and download a clean PI and play with it.
    uhmm i jsut need helped as fast as possible thanks for your help
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    May 2012
    Posts
    474
    Thanks given
    93
    Thanks received
    74
    Rep Power
    634
    You need to declare c as an object. I don't know exactly what it needs to be, but you can figure it out from looking at other classes.
    Reply With Quote  
     

  5. #5  
    Donator

    Join Date
    Mar 2012
    Posts
    179
    Thanks given
    16
    Thanks received
    3
    Rep Power
    9
    yeah thats what ive been doing lol been sorting through files all day im confused lol
    Reply With Quote  
     

  6. #6  
    Super Donator


    Join Date
    Feb 2011
    Age
    27
    Posts
    1,126
    Thanks given
    180
    Thanks received
    178
    Rep Power
    243
    Quote Originally Posted by NoahLH View Post
    yeah thats what ive been doing lol been sorting through files all day im confused lol
    The 'c' shall be an reference to the 'Player' wich the item shall be given too, it should be some paramenter that says Player c into that function.
    Reply With Quote  
     

  7. Thankful users:


  8. #7  
    Donator

    Join Date
    Mar 2012
    Posts
    179
    Thanks given
    16
    Thanks received
    3
    Rep Power
    9
    Quote Originally Posted by Gnakos View Post
    The 'c' shall be an reference to the 'Player' wich the item shall be given too, it should be some paramenter that says Player c into that function.
    could you show me an example?
    Reply With Quote  
     

  9. #8  
    Banned

    Join Date
    Jul 2015
    Posts
    607
    Thanks given
    520
    Thanks received
    660
    Rep Power
    0
    Quote Originally Posted by NoahLH View Post
    could you show me an example?
    post the class and ill give u a fix
    Reply With Quote  
     

  10. #9  
    Donator

    Join Date
    Mar 2012
    Posts
    179
    Thanks given
    16
    Thanks received
    3
    Rep Power
    9
    Quote Originally Posted by Swiffy View Post
    post the class and ill give u a fix
    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 = "";
    			c.getItems().addItem(995, 125000);
    			sendServerMessage("<shad=255>Well done! "+p.playerName + " has quessed the question correctly and earned Coins!");
    		}
    	}
    	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 year was Server first opened?", "2016"},
    		{"<shad=255>[Trivia] What is the highest leveled NPC in the game?", "Corporal Beast"},
    		{"<shad=255>[Trivia] Who created the server originally?", "Owner"},
    		{"<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;
    }
    Reply With Quote  
     

  11. #10  
    Banned

    Join Date
    Jul 2015
    Posts
    607
    Thanks given
    520
    Thanks received
    660
    Rep Power
    0
    Replace

    Code:
    	public static void attemptAnswer(Player p, String attempt) {
    		if (!currentQuestion.equals("") && attempt.replaceAll("_", " ").equalsIgnoreCase(currentAnswer)) {
    			currentQuestion = "";
    			c.getItems().addItem(995, 125000);
    			sendServerMessage("<shad=255>Well done! "+p.playerName + " has quessed the question correctly and earned Coins!");
    		}
    	}
    With:

    Code:
    	public static void attemptAnswer(Client c, String attempt) {
    		if (!currentQuestion.equals("") && attempt.replaceAll("_", " ").equalsIgnoreCase(currentAnswer)) {
    			currentQuestion = "";
    			c.getItems().addItem(995, 125000);
    			sendServerMessage("<shad=255>Well done! "+c.playerName + " has quessed the question correctly and earned Coins!");
    		}
    	}
    Reply With Quote  
     

  12. Thankful user:


Page 1 of 2 12 LastLast

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. [PI] Weapon requirements (easy Question)
    By killag123 in forum Help
    Replies: 2
    Last Post: 08-15-2012, 05:41 AM
  2. Replies: 3
    Last Post: 06-28-2011, 01:27 AM
  3. [PI] Super Fast Easy Question
    By deltanewb in forum Help
    Replies: 7
    Last Post: 01-18-2011, 07:33 AM
  4. PI easy question
    By Star Pker in forum Help
    Replies: 0
    Last Post: 12-01-2010, 03:58 AM
  5. [PI] Easy Question....Rep++ [PI]
    By Kickyamom in forum Help
    Replies: 3
    Last Post: 11-27-2010, 01:24 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •