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

Solved Check if a player fly

Discussion in 'Development' started by Jonas, Mar 10, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    How can i check if a player fly and then kick him when he fly
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    You can do $player->getInAirTicks(), but there will be problem if player was falling
     
  3. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Can you give me an example in which event i can use that
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    public function onMove(PlayerMoveEvent $e){
    $p $e->getPlayer();
    if((
    $player->getInAirTicks() > 30) >= 2000) {
    //Player is flying (When is falling it detect too)
    }
    }
     
    Shockskill likes this.
  5. Shockskill

    Shockskill Silverfish

    Messages:
    15
    GitHub:
    Shockskill
     
  6. Shockskill

    Shockskill Silverfish

    Messages:
    15
    GitHub:
    Shockskill
    or
    PHP:
    if($p->isFlying){
     
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    It is
    PHP:
    if($p->isFlying()){
    EDIT: @Jonas if u want block fly hackers do not use isFlying it is checking only players that has allowFlight by Server
     
    Last edited: Mar 11, 2017
  8. Shockskill

    Shockskill Silverfish

    Messages:
    15
    GitHub:
    Shockskill
  9. Jonas

    Jonas Baby Zombie

    Messages:
    192
    How can i allow Fly?
     
  10. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    allowFlight is like, not a permission. More as though if you were in gamemode c
     
  11. Jonas

    Jonas Baby Zombie

    Messages:
    192
    That wasn't an answer on my question
     
  12. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Just use setAllowFlight function in Player class.
     
  13. Jonas

    Jonas Baby Zombie

    Messages:
    192
    So? Its thats right?
    PHP:
     if($player->hasPermission("allow.fly")){
           
    $player->setAllowFlight();
     
    Last edited: Apr 11, 2017
  14. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Do setAllowFlight(true);
     
  15. Jonas

    Jonas Baby Zombie

    Messages:
    192
  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.