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

how make item drop in x y z with command ?

Comments in 'Plugin Development' started by XWITHERHEROX, Dec 8, 2015.

  1. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    can anybade help me pleace
    i'm started make plugin :oops:
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    $level->dropItem(new Vector3($x$y$z), Item::get($id));
    XWITHERHEROX likes this.
  3. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    lik thits ?
    use pocketmine\math\Vector3;
    use pocketmine\item\Diamond;
    ------------------------------------------------------------------------------------------------------------------------------------------
    public function onCommand(CommandSender $sender,Command $cmd,$label,array $args) {
    if((strtolower($cmd->getName()) == "drop") && isset($args[0])) {
    $player = $this->getServer()->getPlayer($args[0]);
    $level = $sender->getLevel();
    $level->dropItem(new Vector3($x, $y, $z), Item::get(Diamond::CAKE));
  4. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    You should check if $sender and $player are instanceof Player first (use pocketmine\Player), and what are you trying to drop? Diamond or Cake? If its diamond, it should be
    PHP:
    Item::get(Item::DIAMOND);
    also, $x $y $z should be $sender->x , $sender->y and $sender->z respectively
  5. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    lik it
    PHP:
    <?php

    namespace ptc;

    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\TextFormat as Color;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\item\Diamond;

    class 
    main extends PluginBase {
       
        public function 
    onEnable() {
            
    $this->getLogger()->info(Color::GREEN."[ptc] on!");
        }
       
        public function 
    onCommand(CommandSender $sender,Command $cmd,$label,array $args) {
                if(
    $sender instanceof Player) {
                if((
    strtolower($cmd->getName()) == "drop") && isset($args[0])) {
                
    $player $this->getServer()->getPlayer($args[0]);
                
    $level $sender->getLevel();
                
    $level->dropItem(new Vector3($sender->x$sender->y$sender->$z), Item::get(Diamond));
                }
            }
        }
    }
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    This should work

    PHP:
    <?php

    namespace ptc;

    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\TextFormat as Color;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\item\Item;

    class 
    main extends PluginBase {
     
        public function 
    onEnable() {
            
    $this->getLogger()->info(Color::GREEN."[ptc] on!");
        }
     
        public function 
    onCommand(CommandSender $sender,Command $cmd,$label,array $args) {
                if(
    $sender instanceof Player) {
                if((
    strtolower($cmd->getName()) == "drop") && isset($args[0])) {
                
    $player $this->getServer()->getPlayer($args[0]);
    if(
    $player instanceof Player){
                
    $level $player->getLevel();
                
    $level->dropItem(new Vector3($player->x$player->y$player->$z), Item::get(Item::DIAMOND));
    }else 
    $sender->sendMessage("Player not found");
                }
            }
        }
    }
  7. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    server closed :p
  8. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    thnx i fixed
    but i want like
    /drop 133 32 233
  9. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Then
    PHP:
    public function onCommand(CommandSender $sender,Command $cmd,$label,array $args) {
                if(
    $sender instanceof Player) {
                if((
    strtolower($cmd->getName()) == "drop") && count($args)===4) {
                
    $level $this->getServer()->getLevelByName($args[3]);
    if(!
    is_numeric($args[0]) or !is_numeric($args[1]) or !is_numeric($args[2])){$sender->sendMessage("coords must be number");
    return;}
    if(!
    $level){
    $sender->sendMessage("level not found");
    return 
    true;}
                
    $level->dropItem(new Vector3($args[0], $args[1], $args[2]), Item::get(Item::DIAMOND));
                    } else {
                        
    $sender->sendMessage("error");
                }
            }
        }
    iDirtPlayzMC likes this.
  10. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    is give me error
  11. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Post the error if you want help.
  12. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
  13. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    PHP:
    public function onCommand(CommandSender $sender,Command $cmd,$label,array $args) {
                if(
    $sender instanceof Player) {
                if((
    strtolower($cmd->getName()) == "drop") && count($args)===4) {
                
    $level $this->getServer()->getLevelByName($args[3]);
    if(!
    is_numeric($args[0]) or !is_numeric($args[1]) or !is_numeric($args[2])){$sender->sendMessage("coords must be number");
    return;}
    if(!
    $level){
    $sender->sendMessage("level not found");
    return 
    true;}
                
    $level->dropItem(new Vector3($args[0], $args[1], $args[2]), Item::get(Item::DIAMOND));
                    } else {
                        
    $sender->sendMessage("error");
                }
            }
        
    thits the code
    what is problim
    sorry for bad english
  14. XWITHERHEROX
    Offline

    XWITHERHEROX Active Member

    Joined:
    Jun 4, 2015
    Posts:
    57
    Minecraft User:
    ReDaRWiTheR
    his give me my msg error
  15. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    We need to know the error message to find the error, i didnt spot any errors

Share This Page

Advertisement