1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

error Undefined variable: Server

Discussion in 'Facepalm' started by YunoSiwa, Jan 10, 2018.

Thread Status:
Not open for further replies.
  1. YunoSiwa

    YunoSiwa Spider

    Messages:
    9
    I'm trying to execute a function in another plugin but it tells me undefined variable server

    code: 1
    PHP:
    public function PvP($player){

                       
    $plugin $this->getServer()->getPluginManager();
             
    $formapi $plugin->getPlugin("FormAPI");
             
    $form $formapi->createSimpleForm(function (Player $event, array $args){
                 
    $result $args[0];
                 
    $player $event->getPlayer();
                 if(
    $result === null){
                 }
                 switch(
    $result){
                     case 
    0:
            
    $this->gamesf($player);
                     return;

                     case 
    1:
            
    $Server->getInstance()->getPluginManager()->getPlugin("buhc")->app(); //function that I want to execute
                     
    return;

             }
             });
             
    $form->setTitle(TextFormat::WHITE "--= " TextFormat::BOLD TextFormat::DARK_PURPLE "Juegos" TextFormat::RESET TextFormat::WHITE " =--");
             
    $name $player->getName();
             
    $form->addButton("ATRAS");
             
    $form->addButton("BUHC");
             
    $form->sendToPlayer($player);
              }
    Code: 2 error

    PHP:
    public static function app(Player $player){
            
    $this->arenaManager->addNewPlayerToQueue($player); //function that I want to execute
        
    }
    2018-01-10 [01:03:14] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\server\DataPacketReceiveEvent' to 'FormAPI v1.0.0': Undefined variable: Server on jojoe77777\FormAPI\FormAPI
    2018-01-10 [01:03:14] [Server thread/CRITICAL]: ErrorException: "Undefined variable: Server" (EXCEPTION) in "CoreGames/src/YunoSiwa/CoreGames/Main" at line 124
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #0 CoreGames/src/YunoSiwa/CoreGames/Main(124): pocketmine\error_handler(integer 8, string Undefined variable: Server, string C:\Users\usuario\Desktop\VeryImportantPig\plugins\CoreGames\src\YunoSiwa\CoreGames\Main.php, integer 124, array Array())
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #1 FormAPI-master/src/jojoe77777/FormAPI/FormAPI(66): YunoSiwa\CoreGames\Main->YunoSiwa\CoreGames\{closure}(pocketmine\Player object, array Array())
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #2 src/pocketmine/plugin/MethodEventExecutor(38): jojoe77777\FormAPI\FormAPI->onPacketReceived(pocketmine\event\server\DataPacketReceiveEvent object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #3 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(jojoe77777\FormAPI\FormAPI object, pocketmine\event\server\DataPacketReceiveEvent object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #4 src/pocketmine/plugin/PluginManager(721): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\server\DataPacketReceiveEvent object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(91): pocketmine\plugin\PluginManager->callEvent(pocketmine\event\server\DataPacketReceiveEvent object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/protocol/BatchPacket(115): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\ModalFormResponsePacket object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #8 src/pocketmine/Player(2998): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/RakLibInterface(143): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #10 vendor/pmmp/raklib/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.1.68:43921, raklib\protocol\EncapsulatedPacket object, integer 0)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/RakLibInterface(82): raklib\server\ServerHandler->handlePacket()
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #12 src/pocketmine/network/Network(89): pocketmine\network\mcpe\RakLibInterface->process()
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #13 src/pocketmine/Server(2522): pocketmine\network\Network->processInterfaces()
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #14 src/pocketmine/Server(2274): pocketmine\Server->tick()
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #15 src/pocketmine/Server(2149): pocketmine\Server->tickProcessor()
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #16 src/pocketmine/Server(1737): pocketmine\Server->start()
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #17 src/pocketmine/PocketMine(554): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\usuario\Desktop\VeryImportantPig\, string C:\Users\usuario\Desktop\VeryImportantPig\plugins\)
    2018-01-10 [01:03:14] [Server thread/DEBUG]: #18 C:/Users/usuario/Desktop/VeryImportantPig/Phar.phar(1): require(string
     
  2. HyGlobalHD

    HyGlobalHD Spider Jockey

    Messages:
    25
    GitHub:
    HyGlobalHD
    Where Is Your $Server Variable?
    PHP:
    //example variable
    $Server $this->getServer();
     
  3. _XHazardX_

    _XHazardX_ Spider Jockey

    Messages:
    33
    GitHub:
    XHazardX420
    Make sure to have the use pocketmine\Server; and also replace $Server->getInstance()->getPluginManager()->getPlugin("buhc")->app(); with $this->getServer()->getInstance()->getPluginManager()->getPlugin("buhc")->app();
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Nobody asked you to copy the code as-is.
     
Thread Status:
Not open for further replies.
  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.