PHP: use pocketmine\Player; Want to know if the player (pseudo) is online? : PHP: $player = $event->getPlayer()->getName("Pseudo");if($player->isOnline()){//}
PHP: // Search for a player with a name that starts with $name or is $nameif($player = $this->getServer()->getPlayer($name)){//Online} else{//Offline}// Search for a player with a name that is $nameif($player = $this->getServer()->getPlayerExact($name)){//Online} else{//Offline}
PHP: public $players = [];public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); if(isset($this->players[$player->getName()])){ $player->sendMessage("players online ? ".count($this->players)." !"); }}
Can you please don't go on your phone in school because it seems like you didn't listened when you learned to read
All i need is that right? I already defined $players as $challenged ($challenged is who is being challenged) and $name is the sender
Here is code this should help: PHP: <?phpnamespace Hittmana\ChallengerPE; use pocketmine\event;use pocketmine\Server;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\event\Listener;class MainClass extends PluginBase implements Listener{ public function onEnable() { $this->getLogger()->info("ChallengerPE enabled v1.0.4"); $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onDisable() { $this->getLogger()->info("ChallengerPE disabled v1.0.4"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if($sender instanceof Player) { $name = $sender->getName(); $challenged = $this->getServer()->getPlayer($args[0])->getDisplayName(); $thing = $args[1]; if ($command->getName() === "challenge") { $player = $this->getPlayer()->getName($challenged); if ($challenged = $this->getServer()->getPlayer($challenged)){ $this->getServer()->broadcastMessage($name . " challenges " . $challenged . " to " . $thing); } else { $sender->sendMessage($challenged . "cant be found!"); } } } }}
Please stop posting invalid solutions. First of all, what is meant by "the player"? getPlayerExact is more practical for this purpose. You don't want to know that PEMapModder_ is online if you are checking if PEMapModder is online.