Hello guys, i was navigating http://jenkins.pocketmine.net/job/P...player.html#a91a45b539bf270494fec8f687a1295bf and i suddenly saw the function: doFirstSpawn () i have no idea of how to use it, can someone help providing code please??
I don't think you're supposed to use that, that's some internal stuff(for PocketMine, which you shouldn't use).
ohh my god, im so stupid look at this please, how can i get the name of the player?? PHP: <?phpnamespace welcometoserver\lovetobedev;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat as Color;use pocketmine\Player;use pocketmine\Server;use pocketmine\item\Item;use pocketmine\IPlayer;use pocketmine\event\player\PlayerJoinEvent;class Main extends PluginBase{ public function onEnable() { $this->getLogger()->info("Plugin Enabled, new people in your server will be happy!"); } public function onDisable() { $this->getLogger()->info("Plugin Disabled"); } public function hasPlayedBefore(){ $items = [ Item::get(272, 0, 1), Item::get(273, 0, 1), Item::get(274, 0, 1), Item::get(275, 0, 1) ]; Server::getInstance()->broadcastMessage(Color::LIGHT_PURPLE."Welcome Back!"); } } Where can i establish the name??!
you are incorrect! im not using function onCommand!! hahaha, you should learn the api, the fix is here, i just figured out: PHP: $name = $this->getServer()->getPlayer()->getName(); i just finished the plugin, it actually works perfectly!!
and, i think the instanceof Compound is ok for checking the has played before i think let me know, cuz im getting a lot of confusion on that
Note that the doFirstSpawn function is a protected function, which mean you can't access it outside the player class hierarchy. That's PHP not the API. Actually, the Server object does not contain a getPlayer function. Apparently neither of you know what you are doing.
I have no idea what you want to do at all, so how could I help? I am not a mind reader or a fortune teller.
When a player joins store their name in an array, database or config. If you want to send a message to a player when they first join the server, just check to see if that player's name is in the array, database or config and if it isnt send them the message.
What do you mean? I found this. Or, were you saying that there isn't a getPlayer() func with no args?
PHP: public function onJoin(PlayerJoinEvent $event){$player = $event->getName();if(file_exists("players/".strtolower($player->getName()).".dat") == false){$event->setJoinMessage($player->getName()." Joined for the first time :)");}}