Hi how i could do that when i do the command / test it removes me 5 diamond and it gives me 10 chicken ?
Do you know how to register and handle commands? If you do, start with that. Then, in your PluginBase file, you would have a member function onCommand. Assuming this is the only command you have registered, you don't need to worry about the Command or the arguments. I would do something like this after that: PHP: /** CommandSender $sender */ if($sender instanceof Player) { if($sender->getInventory()->contains(Item::get(Item::DIAMOND, 0, 5))) { $sender->getInventory()->addItem(Item::get(Item::COOKED_CHICKEN, 0, 10)); } } If you don't understand commands or PHP basics like conditionals(if, else, etc.), you need to research those before asking questions like this.
You don't need to break; when you return values. I would guess the code isn't being executed, or you would see an error. Can we see the switch() code?
Replace the ; after case "plastron" with a : Also, if you could send the code itself, or a screenshot, that would be much easier. Photos taken from an external device makes it hard to see small details.
I'm sorry, I don't know what you mean. I could fix your problem if you posted it in code blocks, like this: Code: [PHP] *Your code* [/PHP]
PHP: <?phpnamespace grade;use pocketmine\Server;use pocketmine\Player;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\item\Item;use pocketmine\item\enchantment\Enchantment;use pocketmine\item\enchantment\EnchantmentEntry;class Main extends PluginBase{ public function onEnable(){ $this->getLogger()->info("Plugin activer !!"); } public function onDisable(){ $this->getLogger()->info("Plugin Desactiver !!"); } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool { switch ($cmd->getName()){ case "vip"; $sender->sendMessage("====§aVip§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 5 box Extreme"); $sender->sendMessage("- 20 000$"); return true; case "vip+"; $sender->sendMessage("====§aVip+§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /heel"); $sender->sendMessage("- /fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 6 box Extreme"); $sender->sendMessage("- 2 box simple"); $sender->sendMessage("- 40 000$"); return true; case "claziapack"; $sender->sendMessage("====§aClaziaPack§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /heel"); $sender->sendMessage("- Fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 6 box Extreme"); $sender->sendMessage("- 6 box simple"); $sender->sendMessage("- Full Clazia"); return true; case "skyler"; $sender->sendMessage("====§aSkyler§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /heel"); $sender->sendMessage("- Message en rouge"); $sender->sendMessage("- /fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 6 box Extreme"); $sender->sendMessage("- 10 box simple"); $sender->sendMessage("- 100 000$"); $sender->sendMessage("- Full Clazia"); $sender->sendMessage("- 5 pommes de notch"); case "plastron"; if($sender instanceof Player) { if($sender->getInventory()->contains(Item::get(Item::DIAMOND, 0, 5))) { $sender->getInventory()->addItem(Item::get(Item::COOKED_CHICKEN, 0, 10)); } } return true; } } }
PHP: <?phpnamespace grade; use pocketmine\Server; use pocketmine\Player; use pocketmine\event\Listener; use pocketmine\command\CommandSender; use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\item\Item; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\enchantment\EnchantmentEntry;class Main extends PluginBase{ public function onEnable(){ $this->getLogger()->info("Plugin activer !!"); } public function onDisable(){ $this->getLogger()->info("Plugin Desactiver !!"); } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool { switch ($cmd->getName()) { case "vip": $sender->sendMessage("====§aVip§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 5 box Extreme"); $sender->sendMessage("- 20 000$"); return true; break; case "vip+": $sender->sendMessage("====§aVip+§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /heel"); $sender->sendMessage("- /fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 6 box Extreme"); $sender->sendMessage("- 2 box simple"); $sender->sendMessage("- 40 000$"); return true; break; case "claziapack": $sender->sendMessage("====§aClaziaPack§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /heel"); $sender->sendMessage("- Fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 6 box Extreme"); $sender->sendMessage("- 6 box simple"); $sender->sendMessage("- Full Clazia"); return true; break; case "skyler": $sender->sendMessage("====§aSkyler§r===="); $sender->sendMessage("Acces au command:"); $sender->sendMessage("- /feed"); $sender->sendMessage("- /broadcast"); $sender->sendMessage("- /heel"); $sender->sendMessage("- Message en rouge"); $sender->sendMessage("- /fly"); $sender->sendMessage("Items:"); $sender->sendMessage("- 6 box Extreme"); $sender->sendMessage("- 10 box simple"); $sender->sendMessage("- 100 000$"); $sender->sendMessage("- Full Clazia"); $sender->sendMessage("- 5 pommes de notch"); return true; break; case "plastron": if ($sender instanceof Player) { if ($sender->getInventory()->contains(Item::get(Item::DIAMOND, 0, 5))) { $sender->getInventory()->addItem(Item::get(Item::COOKED_CHICKEN, 0, 10)); } } return true; } }}