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

why

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

  1. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i keep messing around with the } but it is annoying i can never get it right it is so fussy
    so here is the code
    case "tpallwarp":
    $data = $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[TPALLWARPS].yml");
    if (isset($params[0])) {
    $name = $params[0];
    if (array_key_exists($params[0], $data)) {
    $x = $data[$params[0]][0];
    $y = $data[$params[0]][1];
    $z = $data[$params[0]][2];
    $level = $this->api->level->get($data[$params[0]][3]);
    }
    }
    }
    }
    if ($name == true){
    foreach(@all as $players){

    $players->teleport(new Position($x, $y, $z, $level));
    $issuer->sendChat("[TPALLWARP] all players have been warped!");

    }
    }

    else {
    $issuer->sendChat("[SimpleWarps] Warp doesnt exists!");
    }
    break;
    }
    public function __destruct() {
    }
    }
    ?>
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Whats with the four curly braces? They dont look helpful to me.
  3. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    Yeah...
    Syriamanal likes this.
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Also, Its great to see that my plugins are good enough to be copied :)
  5. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i have 4 from other cases
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    And why are they closing at that point?
  7. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i am pretty sure they are called parentasis
  8. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i am bad at spelling
  9. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    No. These are parentheses: ( ) These are curly braces: { }
  10. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    no idea if i put them anywhere else it dosnt ike it
  11. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    realy damn
  12. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    But it doesn't work, so it really doesn't like them here either :)
  13. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    no it does it is break down the bottom it dosnt like i cheacked the line
  14. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Could you post the full code and the error you get when you run it
  15. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    Code:
                   
    <?php
    
    /*
    __PocketMine Plugin__
    name=tpall
    version=1.3
    description=tps all player to you
    author=puzzleo
    class=tpall
    apiversion=7,8,9,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"));
            $this ->api-> console->register("tpallspawn", "tps all players to spawn", array($this, "tpallspawn"));
            $this ->api-> console->register("tpallcoords", "tps all players to curtin posistion", array($this, "tpallcoords"));
            $this ->api-> console->register("tpallcreatewarp", "tps all players to warp", array($this, "command"));
            $this ->api-> console->register("tpalldeletewarp", "tps all players to warp", array($this, "command"));
            $this ->api-> console->register("tpallwarp", "tps all players to warp", array($this, "command"));
            $this ->api-> console->register("coords", "tells player coords", array($this, "coords"));
            $this ->api-> console->register("tpalluser", "tps all players to user", array($this, "tpall"));
    $this->config = new Config($this->api->plugin->configPath($this)."[TPALLWARPS].yml", CONFIG_YAML, array());
    console("[INFO] [TPALLWARPS] have Loaded!");
    }
    
        public function tpall($cmd, $args, $issuer){
    
    if($issuer == 'console'){
    
    console("Please run this command in-game.");
    
    } else {
    $this->api->player->tppos("@all","$x","$y","$z");
      $this->api->chat->broadcast("[TPALL]Teleported all players");
    
    }
    }
    
    public function tpallspawn($cmd, $args, $spawn){
    $spawn = $this->api->level->getDefault()->getSpawn();
    $x = $spawn->x;
    $y = $spawn->y;
    $z = $spawn->z;
    $this->api->console->run("tp @all $x $y $z");
    $this->api->chat->broadcast("[TPALL]Teleported all players to spawn");
    }
    public function tpallcoords($cmd, $args, $params){
    $locationX = $params[1];
            $locationY = $params[2];
            $locationZ = $params[3];
            if (count($params) > 4) {
              $locationWorld = $params[4];
            } else {
              $locationWorld = $this->api->level->getDefault();
            }
            $location = new Position($locationX, $locationY, $locationZ, $locationWorld);
    $this->api->player->tppos("@all","locationX","locationY","locationZ");
    $this->api->chat->broadcast("[TPALL]Teleported all players to coords");
    }
    public function tpalluser($cmd, $args, $issuer){
    $this->api->player->teleport("@all",".$issuer");
    $this->api->chat->broadcast("[TPALL]Teleported all players to selected user");
    }
    public function coords($cmd, $args , $issuer, $x, $y, $z , $level, $params, $rawx , $rawy , $rawz){
    if($issuer == 'console'){
    
    console("Please run this command in-game.");
    
    } else {
    $input =$params[0];
    $rawx = floor($issuer->entity->x);
    $x=round($rawx,2);
    $rawy = floor($issuer->entity->y);
    $y=round($rawy,2);
    $rawz = floor($issuer->entity->z);
    $z=round($rawz,2);
    $level = $issuer->level->getName();
    $output ="[TPALL]player is at X: $x Y: $y Z: $z in the world: $level";
    return $output;
    }
    }
    public function command($cmd, $params, $issuer, $alias, $args, $issuer){
    switch ($cmd) {
    case "tpallcreatewarp":
    if (isset($params[0])) {
        $data = $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[TPALLWARPS].yml");
        if (array_key_exists($params[0], $data)) {
        $issuer->sendChat("[TPALLWARPS] Warp has already been created  with that name!");
        }else {
                    $name = $params[0];
            $x = round($issuer->entity->x);
            $y = $issuer->entity->y;
            $z = round($issuer->entity->z);
            $level = $issuer->level->getName()
    ;
    $data["$name"] = array($x,$y,$z,$level);
    $this->api->plugin->writeYAML($this->api->plugin->configPath($this)."[TPALLWARPS].yml", $data);
    $issuer->sendChat("[TPALLWARPS] Warp hass been added!");
    }
        }
        else {
            $issuer->sendChat("Usage: /tpallcreatewarp [NAME]");
        }
    break;
    case "tpalldeletewarp":
    $data = $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[TPALLWARPS].yml");
        if (isset($params[0])) {
            if (array_key_exists($params[0], $data)) {
                unset($data[$params[0]]);
                $this->api->plugin->writeYAML($this->api->plugin->configPath($this)."[TPALLWARPS].yml", $data);
                $issuer->sendChat("[TPALLWARPS] Warp has been removed!");
    
            }else {
                $issuer->sendChat("[SimpleWarp] Warp doesnt exist!");
    }
           
    }else {
        $issuer->sendChat("Usage: /tpalldeletewarp [NAME]");
    }
    break;
    case "tpallwarp":
    $data = $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[TPALLWARPS].yml");
    if (isset($params[0])) {
    $name = $params[0];
        if (array_key_exists($params[0], $data)) {
        $x = $data[$params[0]][0];
        $y = $data[$params[0]][1];
        $z = $data[$params[0]][2];
            $level = $this->api->level->get($data[$params[0]][3]);
    }
    }
    }
    }
    
            if ($name == true){
            foreach(@all as $players){
       
            $players->teleport(new Position($x, $y, $z, $level));
                $issuer->sendChat("[TPALLWARP] all players have been warped!");
    
    }
    }
    
        else {
        $issuer->sendChat("[SimpleWarps] Warp doesnt exists!");
    }
    break;   
    }
    public function __destruct() {
    }
    }
    ?>
    
    well it dosnt thing thee end break is wrong it is the if now
  16. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Copy SimpleWarp
  17. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i know i am gonna change it i just want it to work in the first place so i have something to work off
  18. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    oh well i fixed it now for testing my favorite part of production
  19. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    now only to figure out what this means
    ``
    # PocketMine-MP Error Dump Tue Nov 26 08:18:23 GMT 2013
    Error: array (
    'type' => 1,
    'message' => 'Cannot break/continue 1 level',
    'file' => 'C:\\Users\\Ivett\\Desktop\\PocketMine-MP\\src\\API\\PluginAPI.php(87) : eval()\'d code',
    'line' => 155,
    )
  20. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    what is wrong with break mmmmm

Share This Page

Advertisement