Solved 'Pausing' a scheduled delayed task

Discussion in 'Plugin Development' started by Scullyking, Jan 19, 2014.

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

    Scullyking

    Whats the best/easiest way of pausing a scheduled delayed task when a player leaves (it starts when the player joins).

    I.O.W only have it countdown while the player is online.

    I get that feeling there isn't really an easy way :/ Maybe passing the countdown to a player leave event or something, but I'm lost after there.
     
  2. Offline

    Niknea

    Scullyking Possibly make a if statement checking if the player is online.
     
  3. Offline

    Scullyking

    But when they leave it will still remove the countdown. I want it to pause when they leave and un-pause when they join.

    EDIT: I see what you mean, this will work thankyou! :)
     
  4. Offline

    Compressions

    Scullyking I don't know if there is a thread-safe way of doing this. Possibly, you could run wait() on the task when the player leaves and run notify() when the player joins, but I don't know how that would work out on a synchronous thread.
     
  5. Offline

    Niknea

  6. Offline

    Compressions

    Niknea The problem with sleep() is that it can't be woken up by a certain process.
     
    Garris0n likes this.
  7. Offline

    Scullyking

    Niknea Compressions

    Thanks both for the help, I re-structured some stuff with my plugin so that Kiknea's suggestion of checking if the player is online would work :)
     
    Niknea likes this.
Thread Status:
Not open for further replies.

Share This Page