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
    how can i get pocketmine to send the heal of another player to a player who used a command

    im stuck here-
    btw i like using the switch function :)

    PHP:
    case "health":
                        if(
    $sender instanceof Player) {
                            
    $sender->sendMessage $player->Entity::getHealth();   

                        }
                endswitch;    
  2. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    sorry if i derped out at this point but im really new to php started a week ago.
  3. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    i am going to add the else statement after i get this right..
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then, learn PHP. Look at the OOP section in particular.
  5. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    • Try something more like this:
      Code:
      if($entity instanceof Player){
      $sender->sendmessage("The player ".$player->getname();." has".$player->getHealth(); . "/20 lives");
      }
      else{
      $sender->sendMessage("The player doesn't exist");

    • And your config file will have to be somewhat like this:
    • commands:
      health:
      description: "Gets the amount of health of a player"
      usage: "/health <player>"
      aliases: "h"
      permission: health.allow
  6. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    lol what's end switch mean?
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I don't know, but it is valid PHP code.
    Why the semicolon?
  8. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    it is another way of ending a switch statement:) i like to use it instead of the curly braces:))
  9. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    thank you dude! you are the best!
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    sendMessage is a function. Both of you have syntax errors.
  11. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    you're right I'm sorry its very late I can't think when its late
  12. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    .....
  13. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    you could also do something like this:
    PHP:
    $lol $player->getName()->getHealth();
    $sender->sendMessage($lol);
    CoolGuyPL likes this.
  14. CoolGuyPL
    Offline

    CoolGuyPL New Member

    Joined:
    Sep 24, 2014
    Posts:
    43
    Minecraft User:
    CoolGuyPlays
    is this right?
    PHP:
    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;
  15. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    Use "$player->getName()", PHP is case sensitive. A part from that though, the code looks fine.
    CoolGuyPL likes this.
  16. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    yeah yours is more fixed
    but end it like this cuz pocket mine doesn't use endswitch:
    PHP:
                           }
                }
      }
  17. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    I wasn't paying a tenchion when I wrote it just so sleepy
  18. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    when a person gets the message it should be like:
    The player jeff323 has 19/20 lives
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is same...
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. PocketMine uses PHP 5.6, and PHP 5.6 supports it.

Share This Page

Advertisement