Hi! My first project(Im very new to this) is to change the JoinMessage of the server. Of course its not working for me xD The plugin is starting great with loading enabling usw but it doesnt change the join message. Anyone can help me? Thank you https://pastebin.com/p9YRQjHf
Your Plugin info is in German. Can you say me when your speak German GermanAlso ich habe ein ähnliches Plugin gecodet und habe hier einen Code der Eigentlich funktioniert ich hoffe es hilft dir...) EnglishSo I coded a similar plugin and here I have a code that actually works i hope it helps you ...) public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $event->setJoinMessage(TextFormat : : DARK_RED . "§name ist beigetreten"); }
PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); $event->setJoinMessage(TextFormat : : DARK_RED . $name . " ist beigetreten");} This is the correct code. Don't reply without fixing errors in your code.
Logging the message onLoad, onEnable, and onDisable isn't necessary, and it isn't recommended by PMMP as well, which is the reason why plugins with it gets rejected when submitted. PHP: <?phpdeclare(strict_types=1);namespace Tim\Test1;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\Player;use pocketmine\Server;use pocketmine\event\Listener;use pocketmine\utils\TextFormat;use pocketmine\command\Command;use pocketmine\command\CommandSender;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $event->setJoinMessage(TextFormat : : DARK_RED . $name . " ist beigetreten"); }} Here's your final Main.php.
This was an code that haven't errors Here is my plugin there i have the code https://github.com/GeistFan/JoinLeave
It clearly does, which questions me if you even know php. Variable $name isn’t defined, which will print an error.
No problem! However, if this plugin is for private use, you can still have those messages. It doesn't really matter.