1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to detect if a player moves

Discussion in 'Development' started by XxMegaIs123xX, Aug 28, 2018.

  1. XxMegaIs123xX

    XxMegaIs123xX Silverfish

    Messages:
    18
    How do i detect if a player is moving
    Cuz when he moves it will cancel a task
    Im making a hub plugin btw
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Muqsit likes this.
  3. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I don't think he wants to cancel the movement, but rather the task, like in some warp plugins, or almost like an AFK system.

    I would save the task object in an array with and identifier for the player, like their name, as the key. When they move, get their name, retrieve the task if it exists, and cancel it.
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    Code:
    previousPosition->distance(nextPosition) > 1 (block) -> cancel task
    
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That should work but it's currently bypassable since pmmp doesn't handle immobile flag (which makes it only a client-sided movement lock). An additional PlayerMoveEvent-cancel-when-immobile check would do.
     
    Last edited: Aug 28, 2018
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.