PHP: public function onEquip(\pocketmine\event\entity\EntityArmorChangeEvent $e){$p = $e->getEntity();if(!$p instance of \pocketmine\Player) return;$p->addEffect(\pocketmine\entity\Effect::getEffect(Effect::SPEED)->setDuration(4000));} This does work. But when you rejoin, it gives you an error? PHP: Call to....function getValue() on null (getValue() in \pocketmine\entity\Attribute.php) I have a feeling that I'm doing it wrong. Even tho it works smooth when the player changes armor or anything whlist fully connected. This error happens only when player joins.
PHP: use pocketmine\entity\effect; $effect = Effect::getEffect(2); /* Efeect id */ $effect->setAmplifier(2); /* Effect Power */ $effect->setVisible(true); $effect->setDuration(10000000000); /* Effect Time */ $player->addEffect($effect); /*give player effect */
PHP: !$p instanceof Player will always return false as !$p will be false,maybe the effect gets added to other entities too?
This isn't Java where '!' affects next value on right. It means that `!false` and `!(false)` are both the same. Try to set all Effect attributes - amplifier, visible, duration etc. Use code what @JUZEXMOD provided above, if that doesn't work then it's PocketMine issue.
Yup, PocketMine's issue. But adding a .00001% load (by checking if player has permission) helped me get rid of the console error. This is even more weird... PHP: if(!$p instance of \pocketmine\Player) return;if($p->hasPermission("some.permission") $p->addEffect(\pocketmine\entity\Effect::getEffect(Effect::SPEED)->setDuration(4000));} plugin.yml PHP: permissions: some.permission: default: false By using a permissio plugin (PurePerms), I added that permission to all groups. And now it works. Setting the permission's default value to true didn't help too. SOO weird.