Much Code: PHP: namespace robske_110\Plugin;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\math\Vector3;use pocketmine\tile\Sign;use pocketmine\event\block\SignChangeEvent;use pocketmine\utils\TextFormat;use pocketmine\Player;use pocketmine\utils\Config;use pocketmine\level\Position;use pocketmine\level\Level;//TO-DO://class Main extends PluginBase implements Listener{ public $REQUEST_ISSUER = array(); public $REQUEST_AIM = array(); public $REQUEST_ID = 1; public function onEnable(){ $this->getServer()->getLogger()->info(TextFormat::GOLD . "[TPA+HOME]" . TextFormat::WHITE . " I'm loading..."); @mkdir($this->getDataFolder()); $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML, array()); //$this->config->set('plugin-name',"TPA+HOME"); $this->config->save(); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getLogger()->info(TextFormat::GOLD . "[TPA+HOME]" . TextFormat::WHITE . " I'm loaded!"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch($command->getName()) { case "tpa": if($sender instanceof Player) { if(isset($args[0])) { if(strtolower($args[0]) != "accept" && strtolower($args[0]) != "ja") { $player = $this->getServer()->getPlayer($args[0]); if($player instanceof Player && $player->isOnline() == true) { var_dump($this->REQUEST_ISSUER); //DEBUG var_dump($this->REQUEST_AIM); //DEBUG var_dump($this->REQUEST_ID); //DEBUG $this->REQUEST_ISSUER[$this->REQUEST_ID] = $sender->getName(); $this->REQUEST_AIM[$this->REQUEST_ID] = $args[0]; $this->REQUEST_ID++; var_dump($this->REQUEST_ISSUER); //DEBUG var_dump($this->REQUEST_AIM); //DEBUG var_dump($this->REQUEST_ID); //DEBUG $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat::GREEN . " Der Spieler '".$player->getName()."' muss jetzt /tpa ja eingeben."); $this->getServer()->getPlayer($args[0])->sendMessage("[rBServer]" . TextFormat::GREEN . " '".$sender->getName()."' will sich zu dir Teleportieren! Um das zu erlauben gebe /tpa ja ein."); return true; } else { $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat::DARK_RED . " Der Spieler '".TextFormat::WHITE.$args[0].TextFormat::DARK_RED."' ist nicht online!"); return true; } } else { $AIMINREQUESTARRAY = NULL; $SEARCH_ID = 0; $arrayEmpty = false; $ISSUERINISSUERARRAY = NULL; $ISSUERINREQUESTARRAYasPlayer = NULL; while($AIMINREQUESTARRAY != $sender->getName() && $arrayEmpty != true) { $SEARCH_ID++; if(isset($this->REQUEST_AIM[$SEARCH_ID])) { echo("SearchID:"); var_dump($SEARCH_ID); $AIMINREQUESTARRAY = $this->REQUEST_AIM[$SEARCH_ID]; } else {$arrayEmpty = true;} } if($arrayEmpty == true) //If arrayEmpty is true there was NO request { $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat::DARK_RED . " Es wollte sich niemand zu dir teleportieren! (ErrorCode: ERR_120_arrayEmptyTrue_TPAtriggered)"); return true; } if($arrayEmpty == false) //If arrayEmpty is false then get REQUEST_ISSUER[$SEARCHID] and get the Player by Name { $ISSUERINISSUERARRAY = $this->REQUEST_ISSUER[$SEARCH_ID]; $ISSUERINREQUESTARRAYasPlayer = $this->getServer()->getPlayer($ISSUERINISSUERARRAY); if ($ISSUERINREQUESTARRAYasPlayer != NULL) { $ISSUERINREQUESTARRAYasPlayer->teleport($sender); //WOW This is the teleport part. The rest is just the way of getting these two variables. $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat::GREEN . " Der Spieler '".$ISSUERINREQUESTARRAYasPlayer->getName()."' wurde zu dir teleportiert."); $ISSUERINREQUESTARRAYasPlayer->getPlayer()->sendMessage("[rBServer]" . TextFormat::GREEN . " Du wurdest zu '".$sender->getName()."' teleportiert."); $this->REQUEST_ISSUER[$SEARCH_ID] = $this->REQUEST_ISSUER[$SEARCH_ID]."EXPIRED_USED"; //"Delete" the request! $this->REQUEST_AIM[$SEARCH_ID] = $this->REQUEST_AIM[$SEARCH_ID]."EXPIRED_USED"; //"Delete" the request! var_dump($this->REQUEST_ISSUER); //DEBUG var_dump($this->REQUEST_AIM); //DEBUG var_dump($this->REQUEST_ID); //DEBUG return true; } else { $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat::DARK_RED . " Der Spieler '".TextFormat::WHITE.$ISSUERINISSUERARRAY.TextFormat::DARK_RED."' ist nicht mehr online! (ErrorCode: ERR_121_PlayerFromIIAaPisNull_TPA)"); return true; } } echo("AIMINREQUESTARRAY: "); var_dump($AIMINREQUESTARRAY); echo("ISSUERINREQUESTARRAY: "); var_dump($ISSUERINISSUERARRAY); echo("SEARCH_ID: "); var_dump($SEARCH_ID); echo("RequestIssuer: "); var_dump($this->REQUEST_ISSUER); echo("arrayEmpty: "); var_dump($arrayEmpty); } } else { $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat::DARK_RED . " TPA funktioniert so: /TPA <Spielername>!"); return false; } } else { $this->getServer()->getLogger()->info(TextFormat::DARK_RED . TextFormat::BOLD . "[TPA] ERR_123_ConsoleIssued_TPA"); return true; } There are many problems with this code... But the biggest Problem is: Some description of the situation: Online Players: HeyILikeTPA IWantToGetTeleported HeyILikeTPA issues /tpa IWantToGetTeleported IWantToGetTeleported issues /tpa accept WORKS HeyILikeTPA issues /tpa dashhsa DOES put out error: $sender->getPlayer()->sendMessage("[rBServer]" . TextFormat:ARK_RED . " Der Spieler '".TextFormat::WHITE.$args[0].TextFormat:ARK_RED."' ist nicht online!"); WORKS, fine HeyILikeTPA issues /tpa IWantToGetTele THIS DOES PASS THE INSTANCEOF PLAYER AND THE ONLINE CHECK! AND THEN THE VAR "IWantToGetTele" is written in the array but if the player IWantToGetTeleported issues /tpa accept my plugin calls ERR_121 because IWantToGetTele is not online. Why does pocketmine auto-fill in the missing characters and at the /tpa accept not? How to prevent that auto-filling
The Problem is, that pocketmine accepts IWantToGetTele as player... (But there is IWantToGetTeleported online)
Tha is already in the code: PHP: if($player instanceof Player && $player->isOnline() == true) And the problem is that this PHP: $player = $this->getServer()->getPlayer($args[0]); returns the PlayerObject even if the player name isn't fully written!
PHP: // Where $string is the argumentServer::getPlayerExact($string); Or simply use the players name after you confirm they're a player instance. PHP: // Get a player's name and store it in a variable$name = Player::getName();
But one question: Why is PHP: $ISSUERINREQUESTARRAYasPlayer = $this->getServer()->getPlayer($ISSUERINISSUERARRAY); NOT returning the player object then?
foreach(WHAT?) //I do not exactly know what this helps me?! for is almost the same as while and i never liked for
PHP: $array = ["apple", "peach" => "seed", "banana"]foreach($array as as $key => $data) { echo $key "=>" $data;} Would print Code: "0 => apple" "peach => seed" "2 => banana" http://php.net/manual/en/control-structures.foreach.php