Remove Permanent Windows From Player

Discussion in 'Development' started by ethaniccc, Mar 12, 2020.

  1. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    136
    GitHub:
    ethaniccc
    So, I am using an old version of InvMenu (because I am comfortable with it, and as you can see, I am a complete noob), and I want to get rid of the GUI by using removeWindow or removeAllWindows.

    If I try and use removeWindow:
    PHP:
    $inventory $player->getInventory();
      
           if(
    $item->getId() == 345){
               
    $player->removeWindow($inventory);
               
    sleep(1);
               
    $this->getTeleporter($player);
               return 
    true;
           }
    This comes back:
    Code:
    2020-03-12 [14:51:28] [Server thread/CRITICAL]: InvalidArgumentException: "Cannot remove fixed window 0 (pocketmine\inventory\PlayerInventory) from Epicthic" (EXCEPTION) in "src/pocketmine/Player" at line 3881
    This is because I'm guessing it's a permanent window...

    If I try and use removeAllWindows:
    PHP:
    $inventory $player->getInventory();
        
            if(
    $item->getId() == 345){
                
    $player->removeAllWindows($inventory);
                
    sleep(1);
                
    $this->getTeleporter($player);
                return 
    true;
            }
    Error (I don't understand it @[email protected]):
    Code:
    2020-03-12 [14:54:07] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\Player::removeAllWindows() must be of the type bool, object given, called in C:\Users\schoo\OneDrive\Desktop\skyline_network\plugin_test_server\plugins\LobbyCore\src\ethaniccc\LobbyCore.php on line 2319" (EXCEPTION) in "src/pocketmine/Player" at line 3897
    Can anyone help me? Please don't facepalm me, I know I'm a noob :d
    Thanks!
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,479
    GitHub:
    jasonwynn10
    did you read it? It says "Argument 1 of removeAllWindows() must be bool, not inventory"
     
    ethaniccc likes this.
  3. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    136
    GitHub:
    ethaniccc
    Looks like I really am blind, thanks!
    Apparently it's
    $player->removeAllWindows(true);
     
    jasonwynn10 likes this.

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.