PHP: public function onDeath(PlayerDeathEvent $event) { $player = $event->getPlayer(); //SPAWN LIGHTNING?} i know its sounds involved but I simply dont know how any help thanks!
Please use the search bar https://forums.pmmp.io/threads/how-to-spawn-lightning-strikes-on-player.2675/#post-27629
I saw that swell but what I guess I really mean is how do I except that addStrike function on my player death event? never really messed around with a custom function. Thanks
Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket:utVector3Obj() must be an instance of pocketmine\math\Vector3, null given,
I'm using this, it also contains a parameter for the height: PHP: public function addStrike(Player $p, $height){ $level = $p->getLevel(); $light = new AddEntityPacket(); $light->type = 93; $light->entityRuntimeId = Entity::$entityCount++; $light->metadata = array(); $light->position = $p->asVector3()->add(0,$height,0); $light->yaw = $p->getYaw(); $light->pitch = $p->getPitch(); $p->getServer()->broadcastPacket($level->getPlayers(),$light);}public function onDeath(PlayerDeathEvent $e){ $p = $e->getEntity(); if($p instanceof Player){ $this->addStrike($p,<here comes your height value>); }}
Yes but after I do this how do i call the function into the playerdeathevent? Like how do I make this function happen on PlayerDeathEvent is what I dont know
It's optional and depends on your personal purpose. If you like it exactly at the player then use 0 for the height value. If you like it above the player in the air then use a higher value. ¯\_(ツ)_/¯