Hi! So i want to have a little Welcome Popup when a player joins. My first thought was the following code but i think its more complicated right? https://pastebin.com/CGXGVAnJ
This should work, did you get any error when entering the server? If you do not get any error try to check if you have registered event listener class
Sorry for my bad communication. The pop up is working great. I just want a big popup in the middle of the screen, not just the small one. I mean this: https://i.ytimg.com/vi/C-mbzugSuSU/maxresdefault.jpg
Aaaaa if something it isn't a popup, but a title to send it to the player use: $player->addTitle("Title", "SubTitle"); (you don't need to add subtitle)
Isnt working. Do you see my failure? PHP: public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $fadeInTime = 2; $displayTime = 5; $fadeOutTime = 2; $player->addTitle("Title", "Subtitle", $fadeInTime, $displayTime, $fadeOutTime); }
Are you sure that code is actually executing? Try printing something in console. You probably haven't registered the listener.
It doesn't work because time value must be ticks (1 second is 20 ticks) so your code should look like this: PHP: public function onJoinTitle(PlayerJoinEvent $event) : void { $player = $event->getPlayer(); $fadeInTime = 2 * 20; $displayTime = 5 * 20; $fadeOutTime = 2 * 20; $player->addTitle("Title", "Subtitle", $fadeInTime, $displayTime, $fadeOutTime); }
My listener is there PHP: <?phpdeclare(strict_types=1);namespace Tim\Test1;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\player\PlayerChatEvent;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 onJoinTitle(PlayerJoinEvent $event) : void { $player = $event->getPlayer(); $fadeInTime = 2 * 20; $fadeOutTime = 2 * 20; $displayTime = 5 * 20; $player->addTitle("Title", "Subtitle", $fadeInTime, $displayTime, $fadeOutTime); }
Completely ignored my suggestion of the way that you can debug your code. Make it print something if it actually got executed! Also, let it use default values, which are known to work. So you know that your parameters aren't messing things up.
Sorry for not using your suggestion. Test command worked and i set everything to 1 second. still not working. any ideas left? PHP: <?phpdeclare(strict_types=1);namespace Tim\Test1;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\player\PlayerChatEvent;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 onJoinTitle(PlayerJoinEvent $event) : void { $this->getServer()->getLogger()->info("Test Command"); $player = $event->getPlayer(); $fadeInTime = 1 * 20; $fadeOutTime = 1 * 20; $displayTime = 1 * 20; $player->addTitle("Title", "Subtitle", $fadeInTime, $displayTime, $fadeOutTime); }}
Nope :/ Maybe someone can test it? Would be niceto know if my server is the problem. https://www.dropbox.com/s/39okmunvdrppah1/Test1_v1.0.0.phar?dl=0
I checked it and it works for me, make sure you don't have any other texturepack enabled because it might be blocking the title