Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

i have a doubt.

Comments in 'Plugin Development' started by CoolGuyPL, Sep 26, 2014.

  1. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    any solutions? Untitled.png
  2. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    if you will not show the line of the code that has a fault, how can we fix it?
    PEMapModder likes this.
  3. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    well here-
    PHP:
     public function onCommand(CommandSender $senderCommand $command$label, array $args) {
            if(
    strtolower($command->getName("health"))){
                switch(
    $command->getName()):
            case 
    "health":  //This is to get the health of the player//
                        
    if($entity instanceof Player){
                         
    $sender->sendmessage("The player ".$player->getname()." has".$player->getHealth() . "/20 lives");
                         break;
                        }
                     
                        else {
                        
    $sender->sendMessage("The player doesn't exist");
                        break;
                        }
                        endswitch;
            }
        }
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. What do you expect $command->getName("health") to do?
    2. Please show the whole error message, and specify which line the error message points to.
  5. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    uhh i want it to get the health of the player requested
    and it just shows me a E_NOTICE error that the $entity is an undefined variable.
  6. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    but it doesnt crash the server.
  7. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    The E_NOTICE error is fixed! i just had to replace $enity with $sender!
  8. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    really OK now I'm using it
  9. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    since your new do u know how to make the config and turn it into a .phar
  10. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    you cant turn a config into phar. you can tell pocketmine to generate it.
    PHP:
    aFolder()."config.yml"Config::YAML
  11. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    this one crashes the server dude
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is the code there for?
    You don't need PocketMine to generate a phar.
    $command->getName() is a function that returns the command name. Any parameters you pass are not significant to PHP. PHP is not a human; it can't guess what you want.
    $player->getName() returns a string. You can't call a method upon a string.

Share This Page

Advertisement