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

Solved How To Spawn Lightning Strikes on Player?

Discussion in 'Development' started by Bintang Putra, Jun 9, 2017.

  1. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Hi, i want to spawn lightning strikes on the player

    Here's My Code :
    PHP:
    public function addStrike(Player $p$height)
    {

        
    $player $p;
        
    $level $player->getLevel();
        
    $light = new AddEntityPacket();
        
    $light->type 93;
        
    $light->eid Entity::$entityCount++;
        
    $light->metadata = array();
        
    $light->speedX 0;
        
    $light->speedY 0;
        
    $light->speedZ 0;
        
    $light->yaw $player->getYaw();
        
    $light->pitch $player->getPitch();
        
    $light->$player->x;
        
    $light->$player->y;
        
    $light->$player->z;
        foreach(
    $level->getPlayers() as $player){
            
    $player->dataPacket($light);
        }
    }
    But, Its Return
    Code:
    [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\utils\Binary::writeVarLong_64() must be of the type integer, null given, called in /Users/chaostix/Desktop/pm1/src/pocketmine/utils/Binary.php on line 650" (EXCEPTION) in "/src/pocketmine/utils/Binary" at line 677
    
    
     
  2. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    Use $light->entityRuntimeId instead of $light->eid...
    PHP:
    public function addStrike (Player $player) {

        
    $light = new AddEntityPacket();
        
    $light->type 93;
        
    $light->entityRuntimeId Entity::$entityCount++;
        
    $light->metadata = array();
        
    $light->speedX 0;
        
    $light->speedY 0;
        
    $light->speedZ 0;
        
    $light->yaw $player->getYaw();
        
    $light->pitch $player->getPitch();
        
    $light->$player->x;
        
    $light->$player->y;
        
    $light->$player->z;
        foreach (
    $player->getLevel()->getPlayers() as $player) {
            
    $player->dataPacket($light);
        }
    }
     
    SOFe likes this.
  3. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    PHP:
    public function addStrike(Player $player$height)
    {

        
    $level $player->getLevel();
        
    $light = new AddEntityPacket();
        
    $light->type 93;
        
    $light->entityRuntimeId Entity::$entityCount++;
        
    $light->metadata = array();
        
    $light->speedX 0;
        
    $light->speedY 0;
        
    $light->speedZ 0;
        
    $light->yaw $player->getYaw();
        
    $light->pitch $player->getPitch();
        
    $light->$player->x;
        
    $light->$player->y;
        
    $light->$player->z;
        
    $player->dataPacket($light)
        foreach(
    $player as $p){
            
    $player->dataPacket($light)
        }
    }
    Still Not Working
     
  4. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    I gave you the full code yet you didn't use it. Of course the code above is not going to work. $player is a Player object, you can't foreach it -.-"
     
    OnTheVerge, jasonwynn10 and Sandertv like this.
  5. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Haha Sorry :D

    btw, its solved now, Thanks Man
     
  6. Daniel23

    Daniel23 Witch

    Messages:
    65
    GitHub:
    daniel23
    Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putVector3Obj() must be an instance of pocketmine\math\Vector3, null given,
     
  7. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    use $light->position instead of x, y + z and $light->motion instead of speedX, speedY + speedZ
     
  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.