Hi again . I've been cracking my head on this plugin and i didn't get a way to solve this.. What i need: 1) The command i execute should write in the config. Not an error but this is happening: config.yml PHP: ---format: format... My Command Code: PHP: <?phpnamespace RTG\HUD\command;use pocketmine\{Server, Player, command\Command, command\CommandSender};use pocketmine\command\CommandExecutor;use RTG\HUD\Loader;/** * CustomHUD v 1.0.0 * * @author RTG */class HUDCommand implements CommandExecutor { public function __construct(Loader $plugin) { $this->plugin = $plugin; } public function onCommand(CommandSender $sender, Command $cmd, $label, array $param) { switch(strtolower($cmd->getName())) { case "hud": if(isset($param[0])) { switch($param[0]) { case "toggle": if(isset($this->plugin->enable[strtolower($sender->getName())])) { unset($this->plugin->enable[strtolower($sender->getName())]); $sender->sendMessage("You have turned off CustomHUD!"); } else { $this->plugin->enable[strtolower($sender->getName())] = $sender->getName(); $sender->sendMessage("You have turned on CustomHUD!"); } return true; break; case "format": if(isset($param[1])) { $key = strtolower(array_shift($param)); $this->plugin->cfg->set(format, $key); $this->plugin->cfg->save(); $sender->sendMessage("Passed!"); } else { $sender->sendMessage("Usage: /hud set {format}"); } return true; break; } } else { $sender->sendMessage("Usage: /hud toggle"); } return true; break; } } } Main: PHP: <?phpnamespace RTG\HUD;/* Essentials */use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Server;use pocketmine\scheduler\PluginTask;use pocketmine\command\CommandExecutor;use pocketmine\Player;use pocketmine\utils\Config;use RTG\HUD\Task;use RTG\HUD\command\HUDCommand;class Loader extends PluginBase implements Listener { public $enable; public $cfg; public function onEnable() { @mkdir($this->getDataFolder()); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->warning("Starting..."); $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task($this), 20); $this->enable = array(); /* Config */ $this->cfg = new Config($this->getDataFolder() . "config.yml", Config::YAML); $this->getCommand("hud")->setExecutor(new HUDCommand($this)); } public function onDisable() { } } Task: PHP: <?phpnamespace RTG\HUD;use RTG\HUD\Loader;use pocketmine\Server;use pocketmine\Player;use pocketmine\scheduler\PluginTask;use pocketmine\utils\Config;use pocketmine\plugin\Plugin;class Task extends PluginTask { protected $myPlugin; public function __construct(Loader $plugin) { parent::__construct($plugin); $this->myPlugin = $plugin; } public function onRun($tick) { $online = $this->myPlugin->getServer()->getOnlinePlayers(); $c = $this->myPlugin->getConfig(); foreach($online as $p) { if(isset($this->myPlugin->enable[strtolower($p->getName())])) { $p->sendPopup("->".$c->get("hud")); } } } } Any help would be appreciated...
In your HUDCommand class PHP: $key = strtolower(array_shift($param)); array_shift will remove the first value and return it, so it will remove "format" and return "format" so $key = "format", to fix you just add another array_shift($param); before it PHP: $this->plugin->cfg->set(format, $key); i doubt the plugin will even work though it should be "format" if im not wrong
You've put the array_shift call where you're getting the text to save to the config when it should be in the switch statement. Also, when you're working with strings in PHP make sure you put single or double quotes (when you set the format in the config you don't use quotes).