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

Plugin wont work

Discussion in 'Plugin Help' started by Destroyer57, Jul 5, 2019.

  1. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    I made a plugin to remove items and armor from players inventory when change gamemode but it doesnt work here is code:

    <?php


    namespace inv\clear{

    use pocketmine\event\player\PlayerGameModeChangeEvent;
    use pocketmine\event\Listener;

    class MainClass extends PluginBase implements Listener {

    public function onPlayerGameModeChangeEvent(PlayerGameModeChangeEvent $player){

    $player->getInventory()->clearAll() $player->getArmorInventory()->clearAll(); }

    }
     
  2. notdrewdev

    notdrewdev Spider Jockey

    Messages:
    39
    GitHub:
    drewsucksatlife
    Your $player variable is actually the event, if you want it to work, use $player->getPlayer()->...
     
  3. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    O thx
     
  4. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    Still doesnt work
     
  5. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    you are not listening to the events
     
  6. hexmor

    hexmor Baby Zombie

    Messages:
    110
    GitHub:
    h3xmor
    Try This
    PHP:
    public function onPlayerGameModeChangeEvent(PlayerGameModeChangeEvent $event){
    $player $event->getPlayer();
        
    $player->getInventory()->clearAll()
       
    $player->getArmorInventory()->clearAll(); }
     
  7. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    This is error i get : syntax error, unexpected 'public function onPlayerGame' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)" (EXCEPTION) in "plugins/invclear.phar/src/inv/clear/invclear" at line 11
     
  8. hexmor

    hexmor Baby Zombie

    Messages:
    110
    GitHub:
    h3xmor
    give me plugin . i will fix that
     
  9. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
  10. hexmor

    hexmor Baby Zombie

    Messages:
    110
    GitHub:
    h3xmor
  11. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    Ok try again
     
  12. GianC-Dev

    GianC-Dev Creeper

    Messages:
    5
    GitHub:
    Profee828
    I Fixed
     

    Attached Files:

  13. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    Thanks but im not using pocketmine anymore
     
  14. Deniel

    Deniel Spider Jockey

    Messages:
    42
    GitHub:
    DenielWorld
    Big mistake, PMMP has the best Plugin API that you'll find out there
     
  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.