Help with Timer

Discussion in 'Plugin Development' started by arnie231, Jun 28, 2012.

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

    arnie231

    Ok so iam setting up something that will Broadcast a Message every 10 minutes once it starts but the issue iam having is i want to broadcast like;

    Raid started 60 minutes left
    (10 minutes later)
    Raid started 50 minutes left

    how would i got about doing that

    as right now all i know how to do is send a message every 10 minutes
     
  2. Offline

    r0306

    arnie231
    I'm assuming that you are storing your minutes in a variable for the scheduled repeating task. What you will do is store 60 in a variable 'x', schedule the repeating task at 10 minute intervals and inside, subtract 10 from your variable (which is should now be 50), broadcast the time remaining using the variable 'x', and check if 'x' is equal to 0 and if it is, cancel the current repeating task.
     
  3. Offline

    arnie231

    Thank you very much this has made it so much clearer
     
  4. Offline

    r0306

  5. Offline

    arnie231

    Could i ask a quick question how do i add/subtract in Java/Bukkit and how would i check if it is a certain number ?

    Thank you
     
  6. Offline

    r0306

    arnie231
    These things are pretty basic. To add/subtract you would do something like this.
    Code:
    int number = 60;
    number = number - 10;
    //or
    number -= 10;
    Now to compare it, you would do something like this:
    Code:
    if (number == 0) { //if number equals 0
    Note that one = is an assignment operator and == is a boolean operator. Use the former to store a value and the latter to return a boolean depending on whether the statement is true or false.
     
Thread Status:
Not open for further replies.

Share This Page