Add a second player to InvMenu Event

Discussion in 'Help' started by ZackyVN, Jan 24, 2019.

  1. ZackyVN

    ZackyVN Slime

    Messages:
    89
    I want to add a 2nd player to event
    Like this:
    PHP:
        public function onBanSection(Player $playerPlayer $player2Item $itemClickedOnItem $itemClickedWithSlotChangeAction $action) : bool{
    I try this but it send this error
    Code:
    2019-01-24 [12:58:00] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to muqsit\invmenu\InvMenu::setListener() must be callable or null, array given, called in C:\Users\Administrator\Desktop\Minecraft\HeroMC 1vs1\plugins\Core [SW]\src\Core\command\PunishCommand.php on line 60" (EXCEPTION) in "plugins/Core [SW]/src/muqsit/invmenu/InvMenu" at line 100
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #0 plugins/Core [SW]/src/Core/command/PunishCommand(60): muqsit\invmenu\InvMenu->setListener(array Array())
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #1 plugins/Core [SW]/src/Core/command/PunishCommand(38): Core\command\PunishCommand->openPunishMenu(pocketmine\Player object, pocketmine\Player object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #2 src/pocketmine/command/SimpleCommandMap(261): Core\command\PunishCommand->execute(pocketmine\Player object, string punish, array Array())
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #3 src/pocketmine/Server(2030): pocketmine\command\SimpleCommandMap->dispatch(pocketmine\Player object, string punish mr)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #4 src/pocketmine/Player(2209): pocketmine\Server->dispatchCommand(pocketmine\Player object, string punish mr)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(238): pocketmine\Player->chat(string /punish mr)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/protocol/CommandRequestPacket(54): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleCommandRequest(pocketmine\network\mcpe\protocol\CommandRequestPacket object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(108): pocketmine\network\mcpe\protocol\CommandRequestPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/protocol/BatchPacket(119): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\CommandRequestPacket object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(108): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #10 src/pocketmine/Player(3097): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/RakLibInterface(170): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #12 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.1.5 54381, raklib\protocol\EncapsulatedPacket object, integer 0)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #13 src/pocketmine/network/mcpe/RakLibInterface(110): raklib\server\ServerHandler->handlePacket()
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/RakLibInterface(100): pocketmine\network\mcpe\RakLibInterface->process()
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #15 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #16 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #17 src/pocketmine/Server(2349): pocketmine\snooze\SleeperHandler->sleepUntil(double 1548309480.8339)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #18 src/pocketmine/Server(2209): pocketmine\Server->tickProcessor()
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #19 src/pocketmine/Server(1785): pocketmine\Server->start()
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #20 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Administrator\Desktop\Minecraft\HeroMC 1vs1\, string C:\Users\Administrator\Desktop\Minecraft\HeroMC 1vs1\plugins\)
    2019-01-24 [12:58:00] [Server thread/DEBUG]: #21 (1): require(string phar://C:/Users/Administrator/Desktop/Minecraft/HeroMC 1vs1/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    
     
  2. Muqsit

    Muqsit Wither Skeleton Verified

    Messages:
    1,458
    GitHub:
    muqsit
    Mind explaining what you're trying to do?
     
    corytortoise likes this.
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    626
    You could set the name of the player you wish to ban in the item name and ban $itemClickedOn->getName()

    You may also put colors to the clicked item and ban TextFormat::clean($itemClickedOn->getName())
     
  4. ZackyVN

    ZackyVN Slime

    Messages:
    89
    My code:
    PHP:
        public function onBanSection(Player $playerItem $itemClickedOnItem $itemClickedWithSlotChangeAction $action) : bool{
            if(
    $itemClickedOn->getCustomName() == "§r§aTemporarily Ban"){
                
    $player->sendMessage("§cTest");
                
    $player->removeWindow($action->getInventory());
            }
            return 
    true;
        }
    I want to add a second player to ban. Like this
    PHP:
        public function onBanSection(Player $playerPlayer $player2Item $itemClickedOnItem $itemClickedWithSlotChangeAction $action) : bool{
            if(
    $itemClickedOn->getCustomName() == "§r§aTemporarily Ban"){
                
    $player->sendMessage("§cTest");
               
    $player2->kick("TEst");
                
    $player->removeWindow($action->getInventory());
            }
            return 
    true;
        }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.