Solved I don't remember how to do this...

Discussion in 'Plugin Development' started by ThatGuyWhoDied13, Nov 26, 2013.

Thread Status:
Not open for further replies.
  1. Hey, I dont remember how to create a task that will do something every 20ticks e.g. spawning and killing mobs with custom names or changing the scoreboard I'm using between board1, board2, board3, board4, board5 etc.
    So if anyone could help, thankyou
     
  2. Offline

    exload

  3. exload *faceplams* god dammit how could one be so silly

    exload Wait how would I check how many ticks are left e.g.
    set the scoreboard to 'board1' when it starts
    set the scoreboard to 'board2' at 5 ticks
    set the scoreboard to 'board3' at 10 ticks
    set the scoreboard to 'board4' at 15 ticks
    set the scoreboard to 'board5' at 20 ticks

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

    exload

    Make a repeating task every 5 ticks (you could do every tick if you wanted too). Create a counter and increment the counter each time the task is called. If the counter is equal to 1, 2, 3, or 4 then set the board to the respective name.

    Also every 5 ticks is extremely fast. Players probably won't even be able to see the change.
     
  5. exload I don't know how to create counters...
     
  6. Offline

    xTrollxDudex

    KevyPorter
    http://google.com

    This is what I got:
    PHP:
    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
        public 
    void run() {
        
        }
    }, 
    0L20L);
    There are countless resources for this.
     
  7. Offline

    exload

    KevyPorter
    Code:java
    1. int counter = 0;
    2. scheduleSyncDelayedRepeatingTask (0L, 5L)
    3. counter == 0 : set scoreboard
    4. counter == 1 : set scoreboard
    5. counter == 2 : set scoreboard
    6. etc..
    7. counter ++;
     
  8. exload where does one put this?

    Sorry I'm tired
     
  9. Offline

    calebbfmv

    In a class that implements Runnable..
     
  10. calebbfmv ok and how would I in the scheduler add 1 to the count and if it's 4 set it back to 0 on the next count
     
  11. Offline

    calebbfmv

    int time = 1:
    public void run(){
    stuffffffff{
    }
    time++;
     
  12. Offline

    xTrollxDudex

    KevyPorter
    There are countless imports and in fact, I did release a VERY large portion of my own code because I was having trouble with it, the schedulers do work, just look in my threads created in postings tab of my profile.
     
  13. Offline

    xTrollxDudex

  14. Offline

    HGPDev

    Should i hold a spoon and feed you? (No offence, but i you just want to code. You dont learn anything. If you do it yourself you understand it better.)
     
  15. HGPDev calebbfmv Ok, so I think I figured it out.
    Code:java
    1. public int scorecount = 35;
    2.  
    3. //onEnable
    4. public void onEnable(){
    5. PluginManager pm = .Bukkit.getServer().getPluginManager();
    6. pm.registerEvents(this, this);
    7. }
    8.  
    9. //playerJoin
    10. public void onJoin(PlayerJoinEvent event){
    11. final Player player = event.getPlayer();
    12. player.setScoreboard(board1);
    13. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    14. public void run() {
    15. if(scorecount!= 0){
    16. if (scorecount == 35){
    17. player.setScoreboard(board2);
    18. scorecount--;
    19. }else{
    20. if(scorecount == 34){
    21. player.setScoreboard(board3);
    22. scorecount--;
    23. }else{
    24. if(scorecount == 33){
    25. player.setScoreboard(board4);
    26. scorecount--;
    27. }else{
    28. if(scorecount == 32){
    29. player.setScoreboard(board5);
    30. scorecount--;
    31. }else{
    32. if(scorecount == 31){
    33. player.setScoreboard(board6);
    34. scorecount--;
    35. }else{
    36. if(scorecount == 30){
    37. player.setScoreboard(board7);
    38. scorecount--;
    39. }else{
    40. if(scorecount == 29){
    41. player.setScoreboard(board8);
    42. scorecount--;
    43. }else{
    44. if(scorecount == 0){
    45. //how do I set the scores back to 35
    46. player.setScoreboard(board1);
    47. }
    48. }
    49. }
    50. }
    51. }
    52. }
    53. }
    54. }
    55. }
    56. }
    57. }, 0L, 5L);
    58. }
     
  16. Offline

    calebbfmv

    Well sure.
     
  17. Offline

    calebbfmv

  18. Offline

    HGPDev

    calebbfmv
    I was serious.. Not making fun.. If you justr want the code you dont learn anything. If you make the code by yourself, you learn more.

    Sure! you can ask help on the bukkit forum, but just dont let them do the work for you..
     
    calebbfmv likes this.
Thread Status:
Not open for further replies.

Share This Page