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

How can I make stop player moving?

Discussion in 'Development' started by Hoyee, Mar 9, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    how? I don't know what to start to do.
     
  2. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Try saving the player uuid (or simplier the name) in an array, than on player move you check if he's uuid (or name) it's in the array and cancel the event
     
    Muqsit likes this.
  3. dadodasyra

    dadodasyra Witch

    Messages:
    68
    GitHub:
    dadodasyra
    Why his uuid, just his pseudo. You can use the move event but it is not recommended, it uses a lot of resources
     
  4. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    $p->setImmobile(true);
    $p is a Player
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Not recommended by who?
    Handling the PlayerMoveEvent is the most precise way to deal with movements. Events are almost being called even if you haven't registered the listener, nothing bad in handling it.
    The immobile flag is currently not being handled by pocketmine so it's going to have the same effect as telling a robber not to rob a store and trusting the robber with your word. You could add
    PHP:
    if($player->isImmobile()){
        
    $event->setCancelled();
    }
    in PlayerMoveEvent though.
     
    Mr174 and Invy55 like this.
  6. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Why shoult it use lot of resources?? The event is called already you simply cancel it ;)
     
  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.