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->x = $player->x; $light->y = $player->y; $light->z = $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
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->x = $player->x; $light->y = $player->y; $light->z = $player->z; foreach ($player->getLevel()->getPlayers() as $player) { $player->dataPacket($light); }}
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->x = $player->x; $light->y = $player->y; $light->z = $player->z; $player->dataPacket($light) foreach($player as $p){ $player->dataPacket($light) }} Still Not Working
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 -.-"
Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket:utVector3Obj() must be an instance of pocketmine\math\Vector3, null given,