How do I get when the Player has been afk for 5 minutes?

Discussion in 'Plugin Development' started by x86cam, Jun 16, 2012.

  1. Offline

    x86cam

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I can't seem to figure it out.
    How would I?
  2. Offline

    r0306

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @x86cam
    You can place the player and the current time when they moved in a hashmap. Then in a command, you would call up the current time when the command is sent and compare it to the stored value for the player. Otherwise, you would schedule a repeating task on enable that loops through the hashmap each second and checks if the difference between the current time and the stored values have a difference of 5 minutes.
  3. Offline

    iKeirNez

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  4. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    when is an player afk, when he hasn't moved for the past 5 minuts, then he will standinside an animal farm, so your plugin wont detect it, when looking if an player is afk, you should need to check inventory event, and yaw/pitch chances, I think that thats the best way to detect afk people
  5. Offline

    obnoxint BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  6. Offline

    FTWin01Gurl

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You could track movement by checking every minute through a series of these events:

    1. Get location of the entity
    2. Wait 1 minute (60 * 20 is the ticks, however, because most servers have lots of latency differences, 1200 ticks may not be sufficient).
    3. Get new location
    4. Compare. If new, go to 1. If not new, go to 2.
    1. Clear player from HashMap
    2. Keep player in HashMap, add a minute. Go to 1.
    1. Checks if value is equal to 5, does an action
    Think of this as a flow chart.
    [IMG]
    ferrybig likes this.

Share This Page