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

Ride player code not working

Discussion in 'Development' started by Kabluinc, Jun 11, 2019.

  1. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Hi there, Since PMMP 3.7 or 3.8 i think, this code for letting a player ride another player with a saddle is no longer working. When a player hits a player with a saddle, they are linked to the player but instantly fall off the player (do not stay linked). Is there anything that is wrong with the code or incompatible with recent changes?
    Code:
    PHP:
        public function onDamage(EntityDamageEvent $event){
            if (
    $event instanceof EntityDamageByEntityEvent){
                
    $entity $event->getEntity();
                
    $damager $event->getDamager();
                if (
    $entity instanceof Player && $damager instanceof Player){
                    if (
    $damager->getInventory()->getItemInHand()->getId() == 329) {
                
    $damager->setMotion(new Vector3(00.20));

                
    $pk = new AddEntityPacket();
                
    $pk->type 95;
                
    $pk->entityRuntimeId $entity->getId() * 1000;
                
    $pk->position = new Vector3($entity->x$entity->y$entity->z);
                
    $pk->motion = new Vector3(000);
                
    $pk->metadata = [
                    
    Loader::DATA_RIDE_POSITION => [Entity::DATA_TYPE_VECTOR3F, new Vector3(01.50)]

                ];
                
    $size 0.7;
                
    $size_ = array(30 => 237 => 242 => 2105 => 1.2107 => 2);
                if (isset(
    $size_[95])) $size $size_[95];
                
    $pk->metadata[Entity::DATA_SCALE] = [Entity::DATA_TYPE_FLOAT$size];
                
    $pk->links[] = new EntityLink($entity->getId(), $pk->entityRuntimeId2true);
                foreach (
    $this->getServer()->getOnlinePlayers() as $all) {
                    
    $all->dataPacket($pk);
                }

                
    $link = new SetEntityLinkPacket;
                
    $link->link = new EntityLink($entity->getId() * 1000$damager->getId(), 1true);
                foreach (
    $this->getServer()->getOnlinePlayers() as $all) {
                    
    $all->dataPacket($link);
                }
                return 
    true;
                
    $event->setCancelled(true);
                        }
                    }
                }
            }
        }
     
  2. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Anyone have any idea how to fix this?
     
  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.