Repeating task get time

Discussion in 'Plugin Development' started by TerroDoor, Dec 4, 2019.

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

    TerroDoor

    I have a repeating task every 30 seconds to broadcast a message..

    How would I get the current second the task is on?

    I’m trying to have multiple broadcasts set to different times (10,20,30) for example


    Sent from my iPhone using Tapatalk
     
  2. Offline

    timtower Administrator Administrator Moderator

    @TerroDoor Internal counter? Decrease it every second and check the numbers.
     
  3. Offline

    TerroDoor

    It’s a repeating task, something like this?

    Code:
     
    
    Int seconds =30;
    
    public void run() {
    
    if seconds == 10 
    //broadcast 1
    
    Else if seconds == 20
    //broadcast 2
    }
    
    }, 0, 600);
    
    


    Sent from my iPhone using Tapatalk
     
  4. Offline

    timtower Administrator Administrator Moderator

    @TerroDoor Don't forget to decrease the seconds.
     
  5. Offline

    TerroDoor

    If it’s a repeating task how do I reset the seconds or am I doing that here with “0, 600” ?

    Also, with decreasing, where do I put that? Inside my run method or directly after it’s called?

    “Seconds - -;” ?

    Thanks for your help Tim


    Sent from my iPhone using Tapatalk
     
  6. Offline

    timtower Administrator Administrator Moderator

    @TerroDoor Amount needs to be linked to the timer delay.
    And you stop the timer and start a new one.
     
  7. Offline

    TerroDoor

    Used a repeating task and defined an int variable to 60, inside the run method I started the countdown - -; and checked for each time.

    To repeat the timer I checked if the int was 0 and set it back to 90, continuing the loop again. Thanks @timtower problem solved


    Sent from my iPhone using Tapatalk
     
Thread Status:
Not open for further replies.

Share This Page