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

shouldn't this code work

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

  1. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    public function tpallspawn($cmd, $args, $issuer){

    $x = $mapname->entity->x;
    $y = $mapname->entity->y;
    $z = $mapname->entity->z;
    foreach($this->api->level->get->getSpawn() as $mapname){
    $this->api->console->run("tp @all ".$mapname);
    $this->api->chat->broadcast("Teleported all players to spawn");
    }
  2. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    You haven't defined $mapname in the commandHandler.

    edit: what level should it get?
  3. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    The fixed code:

    PHP:
    public function tpallspawn($cmd$args$issuer){

    $spawn $this->api->level->getDefault()->getSpawn();
    $this->api->console->run("tp @all  ".$spawn);
    $this->api->chat->broadcast("Teleported all players to spawn");

    I hope it works like this. I haven't tested it.
    JassperBeastHD likes this.
  4. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    how do you make it like coordinate s tp?
  5. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Code:
    $x = $issuer->entity->x;
    And so on.. ;)
  6. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    This should work:
    Code:
    public function tpallspawn($cmd, $args, $issuer){
        foreach($this->api->player->getAll() as $p)
        {
            $mapname = "nameofmap";
            $this->api->level->loadLevel($mapname);
            $p->teleport($this->api->level->get($mapname)->getSpawn());
    
        }
    }
    wies likes this.
  7. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Look at your inbox how do i put it?
  8. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i also mean to ask but i guess the anzser is no will my code work i avent tired it
  9. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    can u tell me what a command handler is, i bit of a noob at code
  10. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    You can use my tool to create a basic code. Just create a command and put your code in it. Look for it in the forums.
  11. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    all codes didnt work one crashed the other made players timeout

Share This Page

Advertisement