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

Solved Use LevelEventPacket onJoin

Discussion in 'Development' started by romainbizet46, Oct 26, 2017.

  1. romainbizet46

    romainbizet46 Witch

    Messages:
    52
    Hey i want use LevelEventPackt on onJoin
    But i have this error
    PHP:
    [19:36:38] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'Core v1'Argument 1 passed to pocketmine\utils\BinaryStream::putVarInt() must be of the type integernull givencalled in phar:///home/arma/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/LevelEventPacket.php on line 128 on Core\Main
    code:

    PHP:
    $pk = new LevelEventPacket();
            
    $x $player->getX(); 
            
    $z $player->getZ(); 
            
    $y $player->getY();
            
    $pk->$x;
            
    $pk->$y;
            
    $pk->$z;
            
    $pk->evid LevelEventPacket::EVENT_GUARDIAN_CURSE;
            
    $player->dataPacket($pk);
     
  2. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    1. LevelEventPacket doesn't take x, y, and z anymore. It takes the position as a whole.

    2. You're missing the data parameter.

    So assuming that $player is an instance of Player.
    PHP:
    $pk = new LevelEventPacket();
    $pk->position $player;
    $pk->data 0;
    $pk->evid LevelEventPacket::EVENT_GUARDIAN_CURSE;
    $player->dataPacket($pk);
     
    romainbizet46 likes this.
  3. romainbizet46

    romainbizet46 Witch

    Messages:
    52
    They are no error in console but nothing happen when i join
     
  4. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    You might need to delay it with a task. Test if that's the issue by putting that code under a different event, such as BlockBreakEvent or BlockPlaceEvent.
     
    romainbizet46 likes this.
  5. romainbizet46

    romainbizet46 Witch

    Messages:
    52
    Thx that work fine now :)
     
  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.