You have to try it yourself first, and then ask for help here. Show us what you tried, and what doesn't work.
https://forums.pmmp.io/threads/readme.16/ Don'ts just say "can you give me code" without making any effort to solve your own problem first.
Hello there @Baducai I hope this helps you Libraries: PHP: use pocketmine\plugin\PluginBase as PB;use pocketmine\event\Listener as L;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\item\Item;use pocketmine\utils\TextFormat as TF;use pocketmine\event\player\PlayerInteractEvent; Code for adding effects when you Interact with an Item: PHP: public function onInteract(PlayerInteractEvent $ev){ $player = $ev->getPlayer(); $item = $ev->getItem();#Effects$haste = Effect::getEffect(3); //Effect Id for haste$haste->setDuration(6273); //the Duration for the effect$haste->setAmplifier(2); //Amplifier for effect$haste->setVisible(true);---$speed = Effect::getEffect(1); //Effect Id for Speed$speed->setDuration(6273); //the Duration for the effect$speed->setAmplifier(2); //Amplifier for effect$speed->setVisible(true);--- switch($item->getId()){ case 388: //First Item which is a emerald btw $player->sendMessage(TF::GREEN . "Your wish has been granted"); $player->addEffect($haste); //adds haste effectbreak; case 426: //Second Item which is a ender crystal :) $player->sendMessage(TF::DARK_AQUA . "Your wish has been granted"); $player->addEffect($speed); //adds speed effectbreak; }} I hope this reply helped you to fully understand how to add effects, goodluck with your plugin mate
hummm... This thread is from 3 years ago, with the passage of time the API changes, well here is an example of how to do it in PM3 (currently), although in a few months after PM4 this method will be obsolete. Libraries: PHP: use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\event\player\PlayerInteractEvent; Code: PHP: public function onInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $item = $event->getItem(); $id = $item->getId(); $name = $item->getCustomName(); if ($id == 388 and $name === "Especial Emerald") { //Here you must specify the id of the item with which it will interact and the name of the item. $player->addEffect(new EffectInstance(Effect::getEffect(Effect::HASTE), 20*60, 1, true)); }}