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

Spawn players at other positions in shedule

Comments in 'Plugin Development' started by Bluplayz, Oct 25, 2015.

  1. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Jackboy come twitter please xD
  2. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    So at 19 Uhr xD
  3. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    OK because i dont know how did you mean that with case... Please make an example for your Idea
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    $players $level->getPlayers();
    if(
    count($players == 1) {
      
    $pos = new Position($x$y$z$level);
    }
    if(
    count($players == 2) {
      
    $pos = new Position($x$y$z$level);
    }
    if(
    count($players == 3) {
      
    $pos = new Position($x$y$z$level);
    }
    // Etc..
    $player->teleport($pos);
    This will teleport each player that joins the match to different coordinates depending on how much players are already in the match.
    If a player leaves, the player that just joined will take that empty spot.
  5. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    OK very nice i try it later :D THX did you try it?
  6. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Did you think its work to do $players[0]->teleport .... And $players[1]->teleport to other coords ?
  7. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    PHP:
    for($i 0;$i <= 24;$i++){
                        if (
    $i === 24){
                            
    $player->sendMessage("Game Full");
                            return;
                        }
                        if (!isset(
    $this->seated[$i+1])){
                            
    $seat $i+1;
                            
    $this->seated[$seat] = $name;
                            
    $player->teleport($this->seats[$i]);
                            break;
                        }
                    }
    This will fill in gaps,formed when players leave.
    PHP:
    public function onEnable(){
    $this->seated = array();
    $this->seats = array(new Vector3(-93.5,12,-273.5),
                                new 
    Vector3(-98.5,12,-273.5),
                                new 
    Vector3(-102.5,12,-276.5),
                                new 
    Vector3(-105.5,12,-280.5));
    }
    You might want to do $this->seated = array(); after every game
    PEMapModder likes this.
  8. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    That should work since getPlayers() returns an array of players.
  9. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Nice ist Work ! But i dont Understand completly what are it does , can you make another example ? my Code where i want to put it in is following xD (my english skills xD)
    PHP:
     if($seconds == 0){
      foreach(
    $this->getServer()->getLevelByName("sglobby")->getPlayers()  as $player) {
      
    $player->teleport($this->getServer()->getLevelByName("sg")->getSafeSpawn());

      
    // ? -->$player->teleport(); //dont ask who can teleport , teleport all to other coords in a Array , how?
    }
  10. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    My code basically just checks through all the seats until it finds an empty seat(!isset($this->seated[$i+1])), and when it finds an empty seat, it teleport the player to that seat and set that the seat is occupied ($this->seated[$seat] = $name;)
    if($i === 24) basically means that it has finished checking all the seats, and no empty seats was found, which Game Full.
    You can put this in events like PlayerInteractEvent, onCommand eg.
    If you want the seat to be empty after player leave, just unset($this->seated[$seatNumber])
    Primus likes this.

Share This Page

Advertisement