Create Timer & Point System

Discussion in 'Plugin Development' started by MineoxFX, Jun 21, 2013.

  1. Offline

    MineoxFX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hello Everybody, i am MineoxFX and i am wondering how i can create a timer that when the server reaches its maximum player limit a Timer start from 120 seconds to 0 and it broadcasts how much time is left when in: 2 minutes, 1 minute, 30 seconds, 15 seconds, 10 seconds, 5 seconds, 4 seconds, 3 seconds, 2 seconds and 1 second.

    i Have this code:

    Code:java
    1. this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    2.  
    3. public void run() {
    4. your code here
    5. }
    6. }, 60L);// 60 L == 3 sec, 20 ticks == 1 sec


    But i dont know how to implement it.

    Also i am trying to create a Poin system using the scoreboard i think this can be done using 'dummy' but i really dont know.

    Regards and Thanks in Advance,
    Mineox
  2. Offline

    AmShaegar

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Code:java
    1. public void startCountdown() {
    2. countdown = 120;
    3. countdownTask = new BukkitRunnable() {
    4.  
    5. @Override
    6. public void run() {
    7. switch (--countdown) {
    8. case 10:
    9. case 5:
    10. case 4:
    11. case 3:
    12. case 2:
    13. case 1:
    14. // Do what you want on 10,5,4,3,2,1 seconds left
    15. break;
    16. case 0:
    17. this.cancel();
    18. // Do whatever you want if the countdown is over
    19. break;
    20. default:
    21. if(countdown % 15 == 0) {
    22. // Do something every 15 seconds
    23. }
    24. break;
    25. }
    26. }
    27. }.runTaskTimer(CaptureTheFlag.getPlugin(), 20, 20);
    28. }
  3. Offline

    MineoxFX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks but what is: }.runTaskTimer(CaptureTheFlag.getPlugin(), 20, 20);
    And that wont start when the server is full

    This post has been edited 1 time. It was last edited by MineoxFX Jun 21, 2013.
  4. Offline

    AmShaegar

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    CaptureTheFlag.getPlugin() is my plugin reference.

    runTaskTimer(Plugin, delay, repeat);

    Run first after delay and repeat every repeat ticks.

    This post has been edited 1 time. It was last edited by AmShaegar Jun 22, 2013.

Share This Page