I would like to create a 'Top Player's' on Human's (Human have a top player's skin) When player join, I save his skin: PHP: public function UpdateSkin($player){ file_put_contents($this->getDataFolder().'/skin/'.strtolower($player->getName()).'.skin', $player->getSkinData()); file_put_contents($this->getDataFolder().'/skin/'.strtolower($player->getName()).'.name', $player->getSkinName()); } When server update statistic: PHP: public function onUpdate() $TOP = $this->mysqli->query("/*get top player name")->fetch_assoc(); //We have $TOP = array('login' = $PlayerName) foreach ($this->getServer()->getLevelByName('hub')->getEntities() as $Ent) { if ($Ent instanceof Human && $Ent->x == 50 && $Ent->y == 50 && $Ent->z == 50){ $Ent->setSkin( $this->GetSkin($TOP['login']), $this->GetSkinName($TOP['login']) ); $Ent->setNameTag( $TOP['login'] ); } } } PHP: public function GetSkin($PlayerName){ file_get_contents($this->getDataFolder().'/skin/'.strtolower($PlayerName).'.skin'); } After this, all Human's have not correct skin Is my code rigth?)
What is your logic on the second part? "$TOP" variable is even defined. And what is "$TOP['login']"? If we do not know what is the index "login" how are we supposed to guess what the problem is?
In plugin's datafolder/skin/ will be saved as <name>.skin and .name. PocketMine don't really understand .name and .skin extensions for skin files. Read this maybe it'll help
Code: /*get top player name What? I don't recommend saving two files per player. This is probably unnecessarily slow. What about like this? PHP: public function savePlayer(Player $player){ $data = ["name" => $player->getSkinName(), "data" => $player->getSkinData()]; file_put_contents($this->getDataFolder() . "skins/" . strtolower($player->getName()) . ".sl", zlib_encode(serialize($data), ZLIB_ENCODING_DEFLATE));}public function loadPlayerSkin(string $playerName, &$skinName, &$skinData) : bool{ $path = $this->getDataFolder() . "skins/" . strtolower($playerName) . ".sl"; if(is_file($path)){ $data = unserialize(zlib_decode(file_get_contents($path))); $skinName = $data["name"]; $skinData = $data["data"]; return true; } return false;} About the & operator in front of parameters:http://stackoverflow.com/documentat...rguments-by-reference#t=201608100413050813685
You should also compress it. That's not what I mean. I mean , what is the value of $TOP['login'']? Each index has a value. E.g.: $array["index"] = "value";
okay. Another question: when i set a skin on a human (npc or player), it still doesn't show up. Any idea how i may fix this?