<Hi, Nat Thai people Bad Eng> My code: Spoiler: Code PHP: <?phpnamespace ChatBot;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\Server;use pocketmine\event\player\PlayerChatEvent;use pocketmine\utils\Config;class Loader extends PluginBase implements Listener{ public $config; public function omEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML); } public function onChat(PlayerChatEvent $e) { $p = $e->getPlayer(); $getchat = $e->getMessage(); $chat = strtolower($getchat); $ConfigChat = $this->config->getAll(); foreach ($ConfigChat["Chats"] as $var){ if($Chat == $var["Message"]){ foreach ($ConfigChat["Send"] as $send){ $this->getServer()->broadcastMessage($send); } } } }} Config: Spoiler: Config File Code: #Can Set Player Say in Chat to Send Message Back #Example # - Message: "Hello"; # Send: "Hi" Chats: - Message: "Hello" Send: "hi" - Message: "Good Server" Send: "Thanks for to Rate"
You mixed up the cases on your $chat variable, at one point it's $chat, at another it's $Chat. Assuming you want your bot to respond to the message defined in "Message" with the text defined by "Send", you will need to replace this PHP: foreach ($ConfigChat["Send"] as $send){ $this->getServer()->broadcastMessage($send); } with this PHP: $this->getServer()->broadcastMessage($var["Send"]); At last, the indentation in your php and in your config file is totally messed up. While that doesn't chance functionality of the php file, it does break the yml one. Here's what it should look like: Code: #Can Set Player Say in Chat to Send Message Back #Example: # - Message: "Good Server" # Send: "Thank you" Chats: - Message: "Hello" Send: "hi" - Message: "Good Server" Send: "Thank you"