what wrong my code ? PHP: <?phpnamespace CountPlayer;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\utils\TextFormat as C;class Main extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info(C::GREEN."CountPlayer Has Enable !"); } public function Count(Player $player) { if(count($player) == 1){ $player->sendMessage("Welcome !"); } }}
What is that code trying to do? It has not point. PHP: public function OnJoin(PlayerJoinEvent $event){#Idk what are you trying, but maybe this is what you want.if(count(($players = $this->getServer()->getLevelByName("world")->getPlayers())) == 1){foreach($players as $p){$p->sendMessage("Welcome...?");}}
PHP: public function OnJoin(Player $event){#Idk what are you trying, but maybe this is what you want.if(count(($players = $this->getServer()->getLevelByName("world")->getPlayers())) == 1){foreach($players as $p){$p->sendMessage("Welcome...?");}} its work ? @AndrewBit
Why you change the argument 1 to "Player"? I think that you need learn a lot about PocketMine API... And maybe PHP >.<
Of course it doesn't work. All you did was create a function. Nothing will happen unless you actually use the function.
By the look of your code you don't seem to know php, you should learn it first before you attempt to make a minigame.