Yes, creeper already posted the code for lightning, but it only shows to your self. I want a code of lightning that every one can see? I added creeperface's code and made it on playerdeathevent and it only shows to you when you die and when u kill u cnt see lightning, your just able to see it on death screen when u die? just the code like on hypixel brawl, player dies, lightning shows public
Instead of PHP: $player->datapacket($pk); use PHP: $this->getServer()->broadcastPacket($player->getLevel()->getPlayers(),$pk);
Use EntityDeathEvent , not PlayerDeathEvent or try this plugin , you can extract it and edit to your own needs
PHP: $this->getServer()->broadcastPacket($pk); or PHP: foreach($this->getServer()->getOnlinePlayers() as $p){$p->dataPacket($pk);} or PHP: foreach($p->getLevel()->getPlayers() as $p){$p->dataPacket($p);}
I would personally only send the packet to the players viewers. PHP: foreach($player->getViewers() as $v) { $v->dataPacket($pk);}
PHP: public function onDeath(EntityDeathEvent $ev){ $p = $ev->getPlayer(); $level = $p->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 = $p->getYaw(); $light->pitch = $p->getPitch(); $light->x = $p->x; $light->y = $p->y; $light->z = $p->z; foreach($this->getServer()->getOnlinePlayers() as $p){ $p->dataPacket($pk); } like this?
PHP: public function onDeath(EntityDeathEvent $event) { $victim = $event->getEntity(); if($victim instanceof Player) { $pk = new AddEntityPacket(); $pk->type = 93; $pk->eid = Entity::entityCount++; $pk->metadata = array(); $pk->x = $victim->x; $pk->y = $victim->y; $pk->z = $victim->z; $pk->speedX = 0; $pk->speedY = 0; $pk->speedZ =0; $pk->yaw = $victim->yaw; $pk->pitch = $victim->pitch; foreach($victim->getViewers() as $viewer) { $viewer->dataPacket($pk); } }}
I can't remember if the actual player is included in its viewers or not, if you want to send the Lightning to the player as week just add PHP: $victim->dataPacket($pk);
t the whole code PHP: <?phpnamespace Light;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\Listener;use pocketmine\network\protocol\AddEntityPacket;use pocketmine\network\protocol\SetTimePacket;use pocketmine\network\protocol\TextPacket;use pocketmine\network\protocol\AddPlayerPacket;use pocketmine\entity\Entity;use pocketmine\event\entity\EntityDeathEvent;class Main extends PluginBase implements Listener { public function onEnable(){ $this->getLogger()->info("LightingJoin enabled!"); $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onCommand(CommandSender $sender,Command $cmd,$label,array $args) { if((strtolower($cmd->getName()) == "strike") && isset($args[0])) { if($this->getServer()->getPlayer($args[0]) instanceof Player) { $sender->sendMessage("Player not connected"); } else { $player = $this->getServer()->getPlayer($args[0]); $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->x = $player->x; $light->y = $player->y; $light->z = $player->z; foreach($level->getPlayers() as $pl){ $player->dataPacket($light); } } return true; } } public function onDeath(EntityDeathEvent $event) { $victim = $event->getEntity(); if($victim instanceof Player) { $pk = new AddEntityPacket(); $pk->type = 93; $pk->eid = Entity::$entityCount++; $pk->metadata = array(); $pk->x = $victim->x; $pk->y = $victim->y; $pk->z = $victim->z; $pk->speedX = 0; $pk->speedY = 0; $pk->speedZ =0; $pk->yaw = $victim->yaw; $pk->pitch = $victim->pitch; foreach($victim->getViewers() as $viewer) { $viewer->dataPacket($pk); } } }}