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

Player $data

Comments in 'Plugin Development' started by SuperChipsLP, Nov 10, 2013.

  1. KirkroCrafter
    Offline

    KirkroCrafter Active Member

    Joined:
    Feb 24, 2014
    Posts:
    26
    Minecraft User:
    Kirkro8
    Tutorial? Confusing..
    Try a video.
  2. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Added some comments as explainations :) You can use the schedule function and rand(30, 120); to achieve that. You have to put the above code in a function, of course, and then call it via $this->api->schedule();
  3. zgeorge2222
    Offline

    zgeorge2222 New Member

    Joined:
    Mar 3, 2014
    Posts:
    9
    Minecraft User:
    zgeorge22
    Thanks for the comments. Why did you have to shuffle it though and what was the $times for? Also for my plugin, are you saying that I can loop it using the schedule function? This is what I started with after asking a few people, but I have know idea if this will work or not. I have "simpleworlds" installed btw because each player will be in their own world.
    PHP:
    $playersonline $this->api->player->getAll();
    $player1=$playersonline[0];
    $player2=$playersonline[1];
    //From here on it will be looped until 1 player is dead
    public function swappos(){
    $position1 = new Vector3($player1->entity->x$player1->entity->y$player1->entity->z);
    $level1 $player1->level->getName();
    $position2 = new Vector3($player2->entity->x$player2->entity->y$player2->entity->z);
    $level2 $player2->level->getName();
    if(isset(
    $position1$level1$position2$level2)){
    $this->api->console->run("tp ".$player1." w:".$level2
    $this
    ->api->console->run("tp ".$player1." ".$positon2);
    $this->api->console->run("tp ".$player2." w:".$level1
    $this
    ->api->console->run("tp ".$player2." ".$positon1);
    }else{
    $this->api->chat->broadcast("**UNKNOWN ERROR**");
    }
    }
    $number rand(30,120);
    $this->api->schedule(20*$number,array($this,"swappos"),true'server.schedule');
    Last edited: Mar 7, 2014
  4. zgeorge2222
    Offline

    zgeorge2222 New Member

    Joined:
    Mar 3, 2014
    Posts:
    9
    Minecraft User:
    zgeorge22
    Are you saying I can make the swapping position function loop somehow using a schedule function. It is sort of an "if" loop. If both players are alive then keep swapping every 30-120 seconds, and will be only go to the next thing if 1 player dies. Thanks for any help.
  5. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Put the scheduler into init()
  6. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    And to use the code you have, you'll have to have the coordinates like so
    $x." ".$y." ".$z;
    The /tp command cannot handle Vector3.

Share This Page

Advertisement