$this->getServer()->dispatchCommand(new \pocketmine\command\ConsoleCommandSender(), "setuperm " . $player->getName() . "Test.kit"); Guys can anyone tell me what's wrong here? I just get an error on the getServer()
Please use code blocks when posting code. As @QuiverlyRivalry said, it is important to show us the error. That way we can actually understand what your problem is. Anyways, you are missing a space between the player name and "Test.kit". Example fix: PHP: $this->getServer()->dispatchCommand(new \pocketmine\command\ConsoleCommandSender(), "setuperm {$player->getName()} Test.kit");
How has no one mentioned the biggest issue of all: That code is awfully bad practise, you should access the PurePerms API directly instead of executing a command.
Thanks for the help but now I'm having this error with your code: [11:29:23] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '"', expecting ')'" (EXCEPTION)
Please post the code if you show an error message. I don't know what plugin you are using, but as @HimbeersaftLP pointed out, it seems to be PurePerms. If it has an API, please use that directly. (@HimbeersaftLP seems to know the plugin, so he might be able to tell you about the API.)
As @HimbeersaftLP and @lunix have pointed out you can use the `setPermission()` method in the pureperms plugin. https://github.com/poggit-orphanage...4FF00/PurePerms/data/UserDataManager.php#L200 So for you it would be PHP: $pp = $this->getServer()->getPluginManager()->getPlugin("PurePerms");if(!is_null($pp)){$pp->getUserDataManager()->setPermission($player->getName(), "Test.kit"); }
I see you know about pp,can you help me make a online staff gui? Like if you type /staff it opens a GUI with the online staff members according to the groups they have.
I checked out the plugin and it is really easy to get the online players of a certain group: PHP: $purePerms = $this->getServer()->getPluginManager()->getPlugin('PurePerms');/** @var pocketmine\Player[] $admins */$admins = [];if ($purePerms) { $adminGroup = $purePerms->getGroup('Admin'); // replace 'Admin' with the desired group name if ($adminGroup) { $admins = $purePerms->getOnlinePlayersInGroup($adminGroup); }}// do something with $admins