Hey, I would like to know how to add an item in an inventory to each join of the server (for example a bousole in slot 5) and make it clickable to execute a command, how to put it in a code below: PHP: <?phpnamespace DevJblus;use pocketmine\Player;use pocketmine\Server;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\utils\Config;use pocketmine\utils\Utils;use pocketmine\plugin\PluginBase as Plugins;use DevJblus\Loader;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerLoginEvent;class Main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getLogger()->info("§7========== §eJoinServer §7=========="); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7> §aEnable plugins by DevJblus"); $this->getServer()->getLogger()->info("§7> §aLoading all package"); $this->getServer()->getLogger()->info("§7> §aOpen server ..."); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7================================"); } public function onDisable(){ $this->getServer()->getLogger()->info("§7========== §eJoinServer §7=========="); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7> §cDisable plugins by DevJblus"); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7================================"); } public function onPlayerJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $event->setJoinMessage("§7[§a+§7] " . $player->getName()); } public function onPlayerQuit(PlayerQuitEvent $event) { $player = $event->getPlayer(); $event->setQuitMessage("§7[§c-§7] " . $player->getName()); } public function onPlayerLogin(PlayerLoginEvent $event){ $event->getPlayer()->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn()); }}
PHP: NotjblusNotjblusCreeperNewHey,I would like to know how to add an item in an inventory to each join of the server (for example a bousole in slot 5) and make it clickable to execute a command, how to put it in a code below:PHP:<?phpnamespace DevJblus;use pocketmine\Player;use pocketmine\Server;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\utils\Config;use pocketmine\utils\Utils;use pocketmine\plugin\PluginBase as Plugins;use DevJblus\Loader;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerLoginEvent;class Main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getLogger()->info("§7========== §eJoinServer §7=========="); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7> §aEnable plugins by DevJblus"); $this->getServer()->getLogger()->info("§7> §aLoading all package"); $this->getServer()->getLogger()->info("§7> §aOpen server ..."); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7================================"); } public function onDisable(){ $this->getServer()->getLogger()->info("§7========== §eJoinServer §7=========="); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7> §cDisable plugins by DevJblus"); $this->getServer()->getLogger()->info("§7 "); $this->getServer()->getLogger()->info("§7================================"); } public function onPlayerJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $player->getInventory()->setItem(6, Item::get(Item::COMPASS))->setCustomName("Boussole"); $event->setJoinMessage("§7[§a+§7] " . $player->getName()); } public function onPlayerQuit(PlayerQuitEvent $event) { $player = $event->getPlayer(); $event->setQuitMessage("§7[§c-§7] " . $player->getName()); } public function onPlayerLogin(PlayerLoginEvent $event){ $event->getPlayer()->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn()); }} public function onInteract(PlayerInteractEvent $event){ $player = $event->getPlayer(); if($p->getInventory()->getItemInHand()->getCustomName() == "Boussole"){ $player->sendMessage("réussi !"); }}