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

RemovePlayerPacket

Comments in 'Plugin Development' started by Hotshot_9930, Apr 9, 2016.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Im getting this error when sending the RemovePlayerPacket:
    Code:
    [17:09:50] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'PocketMorph v1.0.0': Argument 1 passed to pocketmine\utils\BinaryStream::putUUID() must be an instance of pocketmine\utils\UUID, null given, called in C:\Users\Kareem\Desktop\PocketMine-MP\src\pocketmine\network\protocol\RemovePlayerPacket.php on line 40 and defined on pocketmorph\EventListener
    
    here is the code:
    PHP:
        public function setMorph(Player $player$morph) {
            
    $entity Entity::createEntity($morph$player->getLevel()->getChunk($player->>> 4$player->>> 4), $this->createNbt($player->x$player->y$player->z$player->yaw$player->pitch));
        
            
    $entity->spawnToAll();
            
    $this->plugin->morphs[$player->getName()] = $entity->getId();
            
    $entity->setNameTag($player->getName());
          
            
    $pk = new RemovePlayerPacket();
            
    $pk->eid $player->getId();
            
    $pk->clientID $player->getClientId();
          
            foreach(
    $this->getPlugin()->getServer()->getOnlinePlayers() as $p) {
                if(
    $p->canSee($player) && $p->getName() !== $player->getName()) {
                    
    $p->dataPacket($pk);
                }
            }
                        
        }
    What is a UUID? Would it make more sense to just hidePlayer() ?
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    $pk->clientID = $player->getClientId();

    It's $pk->clientId not $pk->clientID
    PEMapModder likes this.
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Thanks, but its still telling me
    Code:
    Argument 1 passed to pocketmine\utils\BinaryStream::putUUID() must be an instance of pocketmine\utils\UUID, integer given,
    I have no idea what a UUID is.
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Try $pk->putUUID(UUI:eek::fromData($eid, $skin, $name))
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    Player::hidePlayer(Player $player)
  6. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I've solved it, it works perfectly now.
    This thread helped: https://forums.pocketmine.net/threads/addplayerpacket-and-uuid.12615/
    Also this: https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/utils/UUID.php

    I've changed the code to this:
    PHP:
        public function setMorph(Player $player$morph) {
            
    $entity Entity::createEntity($morph$player->getLevel()->getChunk($player->>> 4$player->>> 4), $this->createNbt($player->x$player->y$player->z$player->yaw$player->pitch));
         
            
    $entity->spawnToAll();
            
    $this->plugin->morphs[$player->getName()] = $entity->getId();
            
    $entity->setNameTag($player->getName());
           
            
    $pk = new RemovePlayerPacket();
            
    $pk->eid $player->getId();
            
    $pk->clientId UUID::fromData($player->getId(), $player->getName());
           
            foreach(
    Server::getInstance()->getOnlinePlayers() as $p) {
                if(
    $p->canSee($player) && $p->getName() !== $player->getName()) {
                    
    $p->dataPacket($pk);
                }
            }
                         
        }
    Thanks to all who replied
    PEMapModder likes this.
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD

Share This Page

Advertisement