Can someone help me with this? PHP: <?phpnamespace Effectsplugin;use pocketmine\Server;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\ConsoleCommandSender;use pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerRespawnEvent; class main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); $this->getLogger()->info("Plugin Enabled"); } public function onPlayerJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $effect = Effect::getEffect(Effect::NIGHT_VISION); $effect->setDuration(99999); $effect->setAmplifier(1); $effect->setVisible(false); $player->addEffect($effect); }}
Use this: PHP: use pocketmine\Server;use pocketmine\Player;use pocketmine\entity\{Effect, EffectInstance};use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\ConsoleCommandSender;use pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerRespawnEvent; class main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); $this->getLogger()->info("Plugin Enabled"); } public function onPlayerJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $player->addEffect(new EffectInstance(Effect::getEffect(Effect::NIGHT_VISION), (99999*20), (1), (false))); }}
i try this and it works but whnever a player respawn he doesnt get the effect PHP: <?phpnamespace Effectsplugin;use pocketmine\Server;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\ConsoleCommandSender;use pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerRespawnEvent; class main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); $this->getLogger()->info("Plugin Enabled"); } public function onPlayerJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $effect = Effect::getEffect((int) 16); $duration = 9999999; $amplification = 2; $visible = false; $instance = new EffectInstance($effect, $duration, $amplification, $visible); $player->addEffect($instance); } public function onPlayerRespawn(PlayerRespawnEvent $event){ $player = $event->getPlayer(); $effect = Effect::getEffect((int) 16); $duration = 9999999; $amplification = 2; $visible = false; $instance = new EffectInstance($effect, $duration, $amplification, $visible); $player->addEffect($instance); }}
im still new in coding sorry but can you make it or just a pattern i can follow cause i really cant make it
PHP: $this->plugin->getScheduler()->scheduleDelayedTask(new ClosureTask(function (?int $currentTick) use($player, $instance): void{ $player->addEffect($instance); }), 5);