Plugin wont work

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

  1. Destroyer57

    Destroyer57 Zombie

    Messages:
    265
    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:
    265
    O thx
     
  4. Destroyer57

    Destroyer57 Zombie

    Messages:
    265
    Still doesnt work
     
  5. Gianluxx

    Gianluxx Spider Jockey

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

    hexmor Baby Zombie

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

    Destroyer57 Zombie

    Messages:
    265
    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:
    160
    give me plugin . i will fix that
     
  9. Destroyer57

    Destroyer57 Zombie

    Messages:
    265
  10. hexmor

    hexmor Baby Zombie

    Messages:
    160
  11. Destroyer57

    Destroyer57 Zombie

    Messages:
    265
    Ok try again
     
  12. GianC-Dev

    GianC-Dev Creeper

    Messages:
    5
    GitHub:
    Profee828
    I Fixed
     

    Attached Files:

  13. Destroyer57

    Destroyer57 Zombie

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

    Deniel Spider Jockey

    Messages:
    30
    GitHub:
    DenielWorld
    Big mistake, PMMP has the best Plugin API that you'll find out there
     

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.