Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to unset fly

Comments in 'Plugin Development' started by tigerza118, Sep 2, 2015.

  1. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    How to unset fly
    sorry i am bad eng
    PHP:
        public function canFly(Player $player){
            return 
    $player->getAllowFlight();
        }

        public function 
    setFlying(Player $player$mode){
            
    $this->getServer()->getPluginManager()->callEvent($ev = new PlayerFlyModeChangeEvent($this$player$mode));
            if(
    $ev->isCancelled()){
                return 
    false;
            }
            
    $player->setAllowFlight($ev->willFly());
            return 
    true;
        }

        public function 
    switchCanFly(Player $player){
            
    $this->players[$player->getName()] = $player->getName();
            
    $this->setFlying($player, !$this->canFly($player), true);
        }

        public function 
    unswitchCanFly(Player $player){
            unset(
    $this->players[$player->getName()]);
            
    $this->setFlying($player, !$this->canFly($player), false);
        }
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $player->setAllowFlight($ev->willFly());
    // What is that!?!?
    // Just use true or false instead of $ev->willFly()..
    Please learn PHP, basically the whole code is wrong.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
     $player->setAllowFlight(false)
    ?
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If it is a switch, you don't need to check if it is switch on or off.
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You don't have to tell us that you have bad English every single time that you make a thread. Also, please learn PHP and the PocketMine API. :p
  6. Deathcrow
    Offline

    Deathcrow Active Member

    Joined:
    Aug 20, 2015
    Posts:
    61
    Minecraft User:
    Deathcrow
    Its funny bc he always says this to everyone:rolleyes: maybe start giving a link ;)

    Anyways this should get you on the tight track:D
    http://docs.pocketmine.net/files.html
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Indeed, he really abused the sentence I have patented ;) I need to sue him for copyright infringement!
    luca28pet likes this.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Maybe i can help you . what do you mean with unsetfly? do you mean to make a player able to fly?
  9. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I can give you a link to learn PHP in 15 min


    and your functions are Invalid. here's the function list:
    Function list
    Last edited: Sep 3, 2015
    SeifValkierks likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    He never said this was an event handler. It can be a simple function.

    Please combine your posts and stop posting consecutive posts. There is an edit button.
  11. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Maybe we should make a LearnPHP bot. XD
  12. SeifValkierks
    Offline

    SeifValkierks New Member

    Joined:
    Sep 4, 2015
    Posts:
    12
    Minecraft User:
    SeifVan

Share This Page

Advertisement