If I use this code Code: $this->db["BlueHome"] = array('x'=>(int)$player->getX(),'y'=>(int)$player->getY(),'z'=>(int) $player->getZ()); it saves in yml like Code: BlueHome: x: 333 "y": 69 z: 241 this. how can I remove " in between y ? and if I use Code: $this->db["blue"]->setRespawnPosition(new Position($this->db["BlueHome"]),$player->getLevel()); this code, server crash and says "Call to a member function setRespawnPosition() on string" (EXCEPTION)
You can't, "y" means true in yaml, that's why it needs to be quoted to interpret it as the letter y. If you absolutely can't stand quotes around the y, you could name your coordinates differently. The Position constructor takes four arguments, not an array, also "$this->db["blue"]->setRespawnPosition" makes no sense at all, what are you trying to do?
You can use a function like this: PHP: private function setupSpawnsForTeam($teamName) { $playerNames = $this->db[$teamName]; foreach ($playerNames as $playerName) { $player = $this->getServer()->getPlayer($playerName); if ($player !== null) { $positions = $this->db[$teamName . "Home"]; $player->setSpawn(new Vector3((int) $positions["x"], (int) $positions["y"], (int) $positions["z"])); } }} Assuming your config looks like this: Code: blue: - Alex - Steve - ChuckNorris blueHome: x: 333 "y": 69 z: 241 P.S. don't forget use pocketmine\math\Vector3;
How can I make Code: blue: - Alex - Steve - notch like this??? It works like Code: blue: Alex blue: Honey blue: steve this.
You can't have it like the second, at least not with standard-compliant yaml, because you'd just override blue every time.
Now I think I understanded what's your saying, but now There is crash of player names. I think it's because of blue : player blue : player blue : player this. So what config should I use about? "Undefined index: player name"
ah.. Now I know how to make -a -b -c like this. but Now it says "Illegal offset type" ~~~ on line 31 here is the line 31 Code: $playerNames = $this->db[$teamName]; and this code is came from Code: private function setupSpawnsForTeam($teamName) { $playerNames = $this->db[$teamName]; foreach ($playerNames as $playerName) { $player = $this->getServer()->getPlayer($playerName); if ($player !== null) { $positions = $this->db[$teamName . "Home"]; $player->setSpawn(new Vector3((int) $positions["x"], (int) $positions["y"], (int) $positions["z"])); } } } and here is the code Code: if( !isset($blueplayers) or !isset($redplayers) ){ $player->sendMessage("ntp"); }//if if( isset($blueplayers) or isset($redplayers) ){ $blueplayers = $this->db["blue"]; $this->setupSpawnsForTeam($blueplayers); $redplayers = $this->db["red"]; $this->setupSpawnsForTeam($redplayers); $this->getServer()->broadCastMessage("w");
You need to $this->setupSpawnsForTeam("blue"); and $this->setupSpawnsForTeam("red"); my function expects a string.
wow I didn't know that I can put "red" inside () it works well, Until I succeeded, I did many strange things to do.
But how can I remove "blue" or "red" or "blueHome" or "redHome" ? by the command, not remove folder inside plugindata