Making Minigame Help

Discussion in 'Plugin Development' started by mkezar, Jul 15, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    mkezar

    Hi. Like most minigames, you right click a sign to join the lobby, you wait until the set amount of players join the lobby, then the game starts, ends, then your teleported back to lobby. I can handle the game making part, just not the lobby part. It is very confusing for me. Right now, i probably sound like a total noob but, I just want to know, Where would i start? :(
     
  2. Offline

    Gater12

    mkezar
    Make your game function only when the game starts.
     
  3. Offline

    MrKeals

  4. Offline

    teej107

    PlayerInteractEvent - use it to detect a sign being clicked
    • Register the required listeners when the game starts, unregister them when the game ends. OR
    • Boolean that reflects if the game is running or not OR
    • Boolean to check the player's location/world
     
  5. Offline

    Msrules123

    If you are making a mini-game, you would want to run the player.sendMessage(player.getName() + " is so ugly they died.") as a console message. (That is just my opinion, I don't think that a lot of mini-games just send messages to only the player that died...


    As for help, I couldn't do any better than to say what teej107 said.

    teej107 GG
     
  6. Offline

    mkezar

    Msrules123 you do know thats my signature.... right...?

    teej107 how do i do playerInteractEvent to a sign with specific chat on the sign? lets say: first line has [Join] second line has The arena name, and third has the number of players in the arena

    OHQCraft Laxer21117 maybe you guys could help. What i want to do is make a lobby that has signs, you click 1 of the join signs, it teleports you to the game lobby, once there is for example 16 people in that lobby, the game starts. Then the game ends and everybody is teleported back to the server lobby. I know how to do the sign teleporting you to the game lobby but i dont know how to test if there are 16 players in that lobby.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
    AoH_Ruthless and dsouzamatt like this.
  7. mkezar Store the value of how many players are currently in the game somewhere. Heck, you probably store the players as they join the game, which would essentially have the value for you.
     
  8. Offline

    teej107

    mkezar
    Code:java
    1. @EventHandler
    2. public void onSignClick(PlayerInteractEvent event)
    3. {
    4. Block block = event.getClickedBlock();
    5. if(block != null)
    6. {
    7. if(block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
    8. {
    9. Sign sign = (Sign)block.getState();
    10. }
    11. }
    12. }

    Here is some example code. First you get the block that the player clicks, make sure it isn't null so you won't get a NPE. Then check to see if the block is a sign (there is a difference between signs on walls and signs that are not on walls), if you read this JavaDoc (especially this method) you'll see why you'll need to call the getState() method. Sign has a number of methods that will help you as well.
     
  9. Offline

    OHQCraft

    nono, that's so inefficient.

    Use this to add Players, definitely don't do it through a command as that is so unpro:
    Code:java
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent event){
    3. if(event.getClickedBlock() instanceof Sign){
    4. Sign clicked = (Sign) event.getClickedBlock();
    5. if(clicked.getLine(0).equals("[Minigame]") && clicked.getLine(1).equals("Arena1")){
    6. //Call your teleport to game function here!
    7. }
    8. }
    9. }


    For quiting the arena just find out when they die and then teleport them back and remove them from any tracking Lists/Maps.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  10. Offline

    Laxer21117

    OHQCraft Lol I know I tried. Don't usually make mini games :p
     
Thread Status:
Not open for further replies.

Share This Page