Hi Guys, I want to create a plugin for my server with which premium players can spawn a pet, which only they themselves see. It should not move, but at a certain place stand in a config file is. The server has several worlds. But I do not know how I spawne the pets and how I make them all except the owner invisible. Here is the code I made: PHP: <?phpnamespace chipscrafterhd\PETS;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\Player;use pocketmine\utils\Config;class PETS extends PluginBase{ public function onEnable() { $this->getLogger()->info(TextFormat::GREEN."wurde geladen!"); @mkdir($this->getDataFolder()); $config = new Config($this->getDataFolder()."config.yml", Config::YAML); $config->set("petpos"); $config->save(); } public function onDisable() { $this->getLogger()->info(TextFormat::RED."wurde deaktiviet."); } public function onLoad() { $this->getLogger()->info(TextFormat::DARK_AQUA."wurde geladen!"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ if(strtolower($command->getName()) === "pets"){ if(count($args) == 1){ $entity = $args; if($entity === "chicken"){ } if($entity === "ozelot"){ } if($entity === "creeper"){ } } else { $sender->sendMessage(TextFormat::RED."/pets <chicken/ozelot/creeper>"); } } return false; } }
Your right, there was no mandatory moving. But, if these people want answers from someone besides you (You seem to be the only one active on these forums any more) , then they will need to go to the new forums.
I would start with something more like this: PHP: <?phpnamespace chipscrafterhd;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\Player;use pocketmine\utils\Config;class Pets extends PluginBase{ public function onEnable() { $this->getLogger()->notice(TextFormat::GREEN."Enabled!"); $this->saveDefaultConfig(); $this->getConfig()->set("petpos",null); } public function onDisable() { $this->getLogger()->notice(TextFormat::GREEN."Disabled!"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ if(strtolower($command) === "pets") { if(count($args) < 1) { return false; } if(!$sender instanceof Player) { $sender->sendMessage(TextFormat::YELLOW."You have to be a Player to use this command!"); return true; } if($sender->hasPermission("pets.cmd")) { $sender->sendMessage(TextFormat::YELLOW."You don't have permission") return true; } if($args[0] == "chicken" or $args[0] == "duck"){ $entity = "chicken"; } if($args[0] == "ocelot" or $args[0] == "ozelot"){ $entity = "ozelot"; } if($args[0] == "creeper"){ $entity = "creeper"; } return true; } }}