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

Solved Disable Flight mode completly

Discussion in 'Development' started by RyanShaw, Dec 30, 2017.

  1. RyanShaw

    RyanShaw Witch

    Messages:
    69
    PHP:
    public function onWorldChange(EntityLevelChangeEvent $event){
              
    $player $event->getEntity();
              
    $target $event->getTarget()->getName();
              if(
    $player->hasPermission("vip.features.use") && $target === "SmallPlot_NEW" OR $target === "BigPlot_NEW" ){
                  
    $player->setAllowFlight(true);
                  
    $player->sendMessage("§aYou are able to fly in this world");
              }
              else{
                  
    $player->setAllowFlight(false);
              }
          }
    Whenever someone obtains flight mode from entering the worlds SmallPlot_NEW or BigPlot_NEW they are allowed to fly. But whenever they move to another world WHILE flying $player->setAllowFlight(false); this doesnt remove fly untill they touch the ground. Meaning they can fly as much as they like as long as they dont touch the ground.. How do i completely take fly off them?
     
    Last edited by a moderator: Dec 30, 2017
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Use [PHP ] tags for your code
     
    Last edited: Dec 30, 2017
    OnTheVerge likes this.
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    fun fact, you can do it for them like this
    PHP:
    public function onWorldChange(EntityLevelChangeEvent $event){
    $player $event->getEntity();
    $target $event->getTarget()->getName();
    if(
    $player->hasPermission("vip.features.use") && $target === "SmallPlot_NEW" OR $target === "BigPlot_NEW" ){
    $player->setAllowFlight(true);
    $player->sendMessage("§aYou are able to fly in this world");
    }
    else{
    $player->setAllowFlight(false);
    }
    }

    if you cant help them you probably shouldnt bother mentioning it


    RE op
    you probably have to forcefully ground them by tping them to ground
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I'm helping him :D When he put tags then there's more chance someone help him because it's easiest to read the code :D
     
    OnTheVerge likes this.
  5. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    would changing their game mode from creative to survival achieve this?
     
    Levi likes this.
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    why not do it for them since you are already helping why not do it all the way?
     
    Kyd, EdwardHamHam and OnTheVerge like this.
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You have to call
    PHP:
    $player->setFlying(false);
    after disabling their ability to fly.
     
  8. RyanShaw

    RyanShaw Witch

    Messages:
    69
    cheers thanks for the help :)
     
  9. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Ill use the tags next time :0
     
  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.