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

what is the problem in this code?

Discussion in 'Plugin Help' started by MadeUpadanaYT, Feb 20, 2017.

  1. MadeUpadanaYT

    MadeUpadanaYT Spider

    Messages:
    12
    what is the problem in this code?
    PHP:
    <?php
    namespace MadeUpadanaYT\ItemProfil;

    use 
    pocketmine\Server;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\item\NetherStar;
    use 
    pocketmine\Player;
    use 
    pocketmine\inventory\Inventory;
    use 
    pocketmine\item\enchantment\Enchantment;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    onebone\economyapi\EconomyAPI;

    class 
    main extends PluginBase implements Listener{

    public function 
    onEnable(){
        
    $this->getLogger()->info("Plugin Sudah Myala");
    }
    public function 
    onDisable(){
        
    $this->getLogger()->info("Plugin Sudah Mati");
    }

    public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
    if(
    $cmd->getName() == "oo"){
            if(
    $sender instanceof Player){
            
    $money EconomyAPI::getInstance()->myMoney($sender);
                   
    $inv $sender->getInventory();
            
    $i Item::get(399,0,1);
                
    $i->setCustomName("§r§eMoney: {$money}");
                
    $inv->addItem($i);
        }
            if(
    $sender instanceof Player){
            
    $player $event->getPlayer();
                   
    $inv $sender->getInventory();
            
    $i Item::get(399,0,1);
                 
    $i->setCustomName("§r§bName: {$player}");
                 
    $inv->addItem($i);
        }
        return 
    true;
      }
    }
    }
    when used will crash like this

    Notice: Undefined variable: event in /storage/emulated/0/Genisys/plugins/a/src/MadeUpadanaYT/ItemProfil/main.php on line 35
    [02:19:00] [Server thread/CRITICAL]: Unhandled exception executing command 'oo' in oo: Call to a member function getPlayer() on unknown
    [02:19:00] [Server thread/CRITICAL]: Error: "Call to a member function getPlayer() on unknown" (EXCEPTION) in "/a/src/MadeUpadanaYT/ItemProfil/main" at line 35
     
    Last edited by a moderator: Mar 5, 2017
  2. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Use the [PHP] [/PHP] tags. They're there for a reason.
     
    HimbeersaftLP likes this.
  3. MadeUpadanaYT

    MadeUpadanaYT Spider

    Messages:
    12
    Can you fix this code?
     
  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.