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

Spawn entity, wich is only visible for one Player.

Comments in 'Plugin Development' started by ChipsCrafterHD, Nov 16, 2016.

?

Is this possible with Pocketmine?

Poll closed Apr 16, 2017.
  1. Yes

    100.0%
  2. No

    0 vote(s)
    0.0%
  1. ChipsCrafterHD
    Offline

    ChipsCrafterHD New Member

    Joined:
    Dec 28, 2015
    Posts:
    4
    Minecraft User:
    ChipsCrafterHD
    Hi Guys,
    I want to create a plugin for my server with which premium players can spawn a pet, which only they themselves see. It should not move, but at a certain place stand in a config file is. The server has several worlds. But I do not know how I spawne the pets and how I make them all except the owner invisible. Here is the code I made:
    PHP:
    <?php

    namespace chipscrafterhd\PETS;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\Config;


    class 
    PETS extends PluginBase{
        public function 
    onEnable() {
            
    $this->getLogger()->info(TextFormat::GREEN."wurde geladen!");
           
            @
    mkdir($this->getDataFolder());
            
    $config = new Config($this->getDataFolder()."config.yml"Config::YAML);
           
            
    $config->set("petpos");
            
    $config->save();
        }
       
        public function 
    onDisable() {
            
    $this->getLogger()->info(TextFormat::RED."wurde deaktiviet.");
        }
       
      
        public function 
    onLoad() {
            
    $this->getLogger()->info(TextFormat::DARK_AQUA."wurde geladen!");
        }
       
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        if(
    strtolower($command->getName()) === "pets"){
           
            if(
    count($args) == 1){
                
    $entity $args;
               
                if(
    $entity === "chicken"){
                   
                }
                if(
    $entity === "ozelot"){
                   
                }
                if(
    $entity === "creeper"){
                   
                }
               
            }
           
            else {
                
    $sender->sendMessage(TextFormat::RED."/pets <chicken/ozelot/creeper>");
            }
           
        }

        return 
    false;
        }  
       
    }

  2. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    i think is to not use spawn to all but spawn to entity
    ChipsCrafterHD likes this.
  3. ChipsCrafterHD
    Offline

    ChipsCrafterHD New Member

    Joined:
    Dec 28, 2015
    Posts:
    4
    Minecraft User:
    ChipsCrafterHD
    Can you please send me a "template" code? Im a beginner :D
  4. SamGamgee55
    Offline

    SamGamgee55 Active Member

    Joined:
    Sep 29, 2016
    Posts:
    52
    Minecraft User:
    SamGamgee55
    Please post this on the other forums. Thanks!!!
    archie426 and HimbeersaftLP like this.
  5. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    nope sorry i dont have spare time to do so
    but that is roughly the example
    pro tip use an ide
    ChipsCrafterHD likes this.
  6. archie426
    Offline

    archie426 Active Member

    Joined:
    Apr 26, 2015
    Posts:
    193
    Minecraft User:
    archie426
    Please stop replying to this, move it to the new forums
    HimbeersaftLP likes this.
  7. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    there no mandatory moving so what's the issue?
  8. Magicode
    Offline

    Magicode Active Member

    Joined:
    Aug 3, 2016
    Posts:
    54
    Minecraft User:
    PokemonHero101
    Your right, there was no mandatory moving. But, if these people want answers from someone besides you (You seem to be the only one active on these forums any more) , then they will need to go to the new forums.
    HimbeersaftLP and Thunder33345 like this.
  9. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Code:
    public function spawnTo(Player $player){
  10. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    agreed on this one
    yeah i should note to tell them to move when i an trying to help them that
    HimbeersaftLP likes this.
  11. jasonwynn10
    Offline

    jasonwynn10 Active Member

    Joined:
    Dec 20, 2015
    Posts:
    87
    Minecraft User:
    jasonwynn10
    I would start with something more like this:
    PHP:
    <?php
    namespace chipscrafterhd;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\Config;


    class 
    Pets extends PluginBase{
        public function 
    onEnable() {
            
    $this->getLogger()->notice(TextFormat::GREEN."Enabled!");

            
    $this->saveDefaultConfig();
            
    $this->getConfig()->set("petpos",null);
        }
       
        public function 
    onDisable() {
            
    $this->getLogger()->notice(TextFormat::GREEN."Disabled!");
        }
       
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
            if(
    strtolower($command) === "pets") {
                if(
    count($args) < 1) {
                    return 
    false;
                }
                if(!
    $sender instanceof Player) {
                    
    $sender->sendMessage(TextFormat::YELLOW."You have to be a Player to use this command!");
                    return 
    true;
                }
                if(
    $sender->hasPermission("pets.cmd")) {
                    
    $sender->sendMessage(TextFormat::YELLOW."You don't have permission")
                    return 
    true;
                }
                if(
    $args[0] == "chicken" or $args[0] == "duck"){
                    
    $entity "chicken";
                }
                if(
    $args[0] == "ocelot" or $args[0] == "ozelot"){
                    
    $entity "ozelot";
                }
                if(
    $args[0] == "creeper"){
                    
    $entity "creeper";
                }
                return 
    true;
            }
        }
    }

Share This Page

Advertisement