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

my plugin dosent work why

Comments in 'Plugin Development' started by Puzzleo, Nov 14, 2013.

  1. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    PHP:
    <?php
     
    /*
    __PocketMine Plugin__
    name=tpall
    description=teleports all players to you
    version=1.0
    author=puzzleo
    class=tpall
    apiversion=10
    */
     
    class tpall implements Plugin
    {
        public function 
    __construct(ServerAPI $api$server false)
        {
            
    $this->api $api;
        }
     
        public function 
    init()
        {
            
    $this ->api-> console->register("tpall""tps all players", array($this"tpall"));
            
    $this->api->ban->cmdWhitelist("tpall");
        }
     
     
        public function 
    tpall($level$target){
        
    $this->api->player->getAll();
        
    $this->api->player->teleport("$level","$target");
        }
     
     
            public function 
    __destruct() {
        }
        }
    Last edited: Nov 14, 2013
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Do you know PHP or java or C or alike languages enough?
    If you do, you should know that getAll() does nothing if you don't collect the return value.

    Even if you don't know PHP, you should know a logical problem: How can the script interpreter know where you want to teleport players to?

    Also, why do you think that $level and $target will be the params? Whatever your parameter names are, their value are the same. (command typed, params)

    Let me do this for you:
    PHP:
    public function tpall($c,$p){
      
    $players=$this->api->player->getAll();
      
    $x=/*type x axis here*/;
      
    $y=/*type y axis here*/;
      
    $z=/*type z axis here*/;
      
    $vec=new Vector3($x,$y,$z);
        foreach(
    $players as $player){
          
    $player->teleport($vec);//This is a simpler method
        
    }
    }
  3. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=tpall
    description=teleports all players to you
    version=1.0
    author=puzzleo
    class=tpall
    apiversion=10
    */

        
    class tpall implements Plugin{
        {
     
        public function 
    __construct(ServerAPI $api$server false) {
        {
        
    $this->api $api;
       
        }


        public function 
    init(){
            
    $this ->api-> console->register("tpall""tps all players", array($this"tpall"));
        }

      public function 
    tpall(){
      
    this->api->player->teleport("$players","$player");
    }


            public function 
    __destruct() {
        }
        }
        
    ?>
    why doesnt this work
    Last edited: Nov 14, 2013
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn PHP. $players and $player are undefined.
    Also $ before this.

    Wait... What do you want the plugin to do? TP all to where? What do you think $players and $player mean? ...
  5. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    This should fix your plugin.

    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=tpall
    description=teleports all players to you
    version=1.0
    author=puzzleo
    class=tpall
    apiversion=10
    */

        
    class tpall implements Plugin{
        {

    private 
    $api;

        public function 
    __construct(ServerAPI $api$server false) {
        {
        
    $this->api $api;

        }


        public function 
    init(){
            
    $this ->api-> console->register("tpall""tps all players", array($this"tpall"));
        }

      public function 
    tpall($cmd$args$issuer){

    if(
    $issuer == 'console'){

    console("Please run this command in-game.");

    } else {

      
    $this->api->console->run("tp @all ".$issuer);

    }
    }


            public function 
    __destruct() {
        }
        }
        
    ?>

    And you might add
    PHP:
    $this->api->chat->broadcast("Teleported all players to ".$issuer); 
    to rhe command function.
    Last edited: Nov 14, 2013
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $issuer->username might be better.
  7. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    inst $player the same as $issuer and $players the same as @all or am i wrong?
  8. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
  9. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    oh ok thanks :)
  10. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Or easieer:
    Code:
    $this->api->console->run("tp @a " . $issuer . "");
    
    Is it?
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then the easier is to grant the player the ability to tp people
    Because it is possible just to you command
    /tp @a PEMapModder

Share This Page

Advertisement