Hello, I am practically new to Pocketmine, I have only been with this one year, which I have always used poggit plugins but I do not always find what I need so I have ventured into trying to create plugins for my own server, my knowledge in php It is null. I have tried to get the nametag of a player with the rank of PurePerms / PureChat but I have run into this error I have looked in several pages but I have not found a solution. Error: Code: [Server thread/CRITICAL]: ErrorException: "Array to string conversion" (EXCEPTION) in "plugins/EnderCore/src/Core/Core" at line 61 Code: PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $rank = $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr($player)->getGroup($player); $nametag = $this->getServer()->getPluginManager()->getPlugin("PureChat")->getConfig()->get("groups", $rank, "nametag"); $event->setJoinMessage(""); $this->getServer()->broadcastMessage($nametag ."§r§7 has joined the server");}
Sorry I had not realized xD Is: Code: [Server thread/CRITICAL]: ErrorException: "Array to string conversion" (EXCEPTION) in "plugins/EnderCore/src/Core/Core" at line 61
$nametag is not string, but array instead do PHP: var_dump($nametag); to see exact contents of that variable. Perhaps the value you're looking for is inside that array.
Now this error: Code: array(4) { ["Guest"]=> array(3) { ["chat"]=> string(61) "&7[Guest] &f{fac_rank}{fac_name}&a {display_name} &7> &f{msg}" ["nametag"]=> string(26) "&7[Guest] &f{display_name}" ["worlds"]=> array(0) { } } ["Admin"]=> array(3) { ["chat"]=> string(61) "&c[Admin] &7{fac_rank}{fac_name}&6 {display_name} &d>&b {msg}" ["nametag"]=> string(49) "&a[Admin]&e {fac_rank}{fac_name} &6{display_name}" ["worlds"]=> array(0) { } } ["Owner"]=> array(3) { ["chat"]=> string(64) "&d[Owner] &c{fac_rank}{fac_name} &b{display_name} &c>&6> &b{msg}" ["nametag"]=> string(49) "&d[Owner]&c {fac_rank}{fac_name} &b{display_name}" ["worlds"]=> array(0) { } } ["OP"]=> array(3) { ["chat"]=> string(77) "&a[OP] &5{fac_rank}{fac_name}&b {prefix}{display_name}{suffix} &c>&6> &f{msg}" ["nametag"]=> string(46) "&a[OP] &c{fac_rank}{fac_name} &b{display_name}" ["worlds"]=> array(0) { } } } [08:14:54] [Server thread/CRITICAL]: ErrorException: "Array to string conversion" (EXCEPTION) in "plugins/EnderCore/src/Core/Core" at line 62 Code: PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $rank = $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr($player)->getGroup($player); $nametag = $this->getServer()->getPluginManager()->getPlugin("PureChat")->getConfig()->get("groups", $rank, "nametag"); var_dump($nametag); $event->setJoinMessage(""); $this->getServer()->broadcastMessage($nametag ."§r§7 has joined the server");} Error line: PHP: $this->getServer()->broadcastMessage($nametag ."§r§7 has joined the server");
PHP: $this->getServer()->broadcastMessage($nametag[$rank] ."§r§7 has joined the server"); I won't go into details.
Code: [Server thread/CRITICAL]: ErrorException: "Illegal offset type" (EXCEPTION) in "plugins/EnderCore/src/Core/Core" at line 62
Now dump the $rank variable, I was just assuming that $nametag contains all registered groups and $rank is the group the player is assigned to. $nametag could also be array of the inheritance tree. Getting the last element from the array might resolve this.
Try to use this: PHP: $this->getServer()->broadcastMessage($nametag[$rank]["nametag"]."§r§7 has joined the server");
Hi guys I found the solution by looking at the PureChat code. For those who want to know how I got the nametag... I have used these variables: PHP: $player = $event->getPlayer();$levelName = $this->getServer()->getPluginManager()->getPlugin("PureChat")->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null;$nametag = $this->getServer()->getPluginManager()->getPlugin("PureChat")->getNametag($player, $levelName); An example where I use the nametag that pureperms assigns you: PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $levelName = $this->getServer()->getPluginManager()->getPlugin("PureChat")->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null; $nametag = $this->getServer()->getPluginManager()->getPlugin("PureChat")->getNametag($player, $levelName); $event->setJoinMessage(""); $this->getServer()->broadcastMessage($nametag ."§r§7 has joined the server");}