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

Packet for Player if he try to fly in survival

Discussion in 'Development' started by Bluplayz, Feb 15, 2017.

  1. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    The event PlayerToggleFlightEvent only called if the player try double tap the jump button in creative (try to fly in creative) but is there any Packet which send to the player when he try it in survival?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    question unclear, if you meant to allow fly in survival i remember there a setfly or something named similar
     
  3. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    xD i know ^^ i want to implement something like "double-jump" in my lobby
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you can try creating a onmove listener and if player rapidly jump twice within X time then you can do whatever you want there
     
  5. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    but i want to check if a player press the jump button if he is already in the air :=) i need to do this with packets but which packet i should check for this? does MCPE only send packets if player toggle jump in creative and spectator gamemode?
     
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    You just need to listen for PlayerActionPacket action 8
    https://github.com/pmmp/PocketMine-...e/network/protocol/PlayerActionPacket.php#L38
    Code:
    [13:30:54] [Server thread/DEBUG]: [PacketLogger] object(pocketmine\network\protocol\PlayerActionPacket)#12444 (9) {
      ["eid"]=>
      int(0)
      ["action"]=>
      int(8)
      ["x"]=>
      int(0)
      ["y"]=>
      int(0)
      ["z"]=>
      int(0)
      ["face"]=>
      int(0)
      ["isEncoded"]=>
      bool(false)
      ["offset"]=>
      int(7)
      ["buffer"]=>
      string(14) "24001000000000"
    }
    
    I don't know why mcpe sends no coordinates here though...
     
    MalakasPlayzMCPE, SOFe and Bluplayz like this.
  7. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    Ah thank you :) i will try something later ^^
     
  8. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    works good, but it dont call when i tap the jump button and i am already in the air :/
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Provide the code you used to listen for the event.
     
  10. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    PHP:
    public function onDataPacketReceive(DataPacketReceiveEvent $event)
    {
        
    $packet $event->getPacket();
        if (
    $packet instanceof PlayerActionPacket) {
            
    $this->plugin->getLogger()->warning("DataPacket: PlayerActionPacket was received with action id: " $packet->action);
        }
    }
    simple ^^
    PHP:
    $packet->action
    only returns action ID 8 if i tap jump and if i am not in the air ^^
     
    Skullex, jasonwynn10 and Muqsit like this.
  11. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Set flying on jump. Haven't tested this tho.
    PHP:
    public function setFlyOnJump(PlayerToggleFlightEvent $event) {
           
    $player $event->getPlayer();
        
            if(
    $event->isFlying() && $player->getGamemode() !== 1) {
                
    $player->setFlying(false);
                
    $jump $player->getLocation()->multiply(0.2);
                
    $jump->1.1;
                
    $player->setMotion($jump);
                
    $event->setCancelled(true);
            } elseif (
    $player->getGamemode() === 0$player->setFlying(true);
        }
     
  12. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
    the event will not called when you jump in survival ^^
     
    jasonwynn10 likes this.
  13. CraftYourBukkit

    CraftYourBukkit Creeper

    Messages:
    3
    There's no packet being sent when pressing jump in Survival & you're not on the ground (unless you're using hacks)
     
    dktapps likes this.
  14. Enes5519

    Enes5519 Spider Jockey

    Messages:
    28
    GitHub:
    Enes5519
    PHP:
    public function onMove(PlayerMoveEvent $e){
        
    $o $e->getPlayer();
        if(
    $o->isSurvival() && $o->moveFlying()){
            
    // not tested
        
    }
    }
     
    Last edited: Mar 4, 2017
  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.