1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Teleport every player in arena to another game?

Discussion in 'Facepalm' started by Kyd, Jun 29, 2017.

  1. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Create a key in $arenas[] and reset it to 0 when the game ends. The key will be used for incrementing spawn keys in the array.
    PHP:
    //You will need to define $this->arenas["sw-1"]["increments"] = 0;
    public function joinToArena(Player $p){
        
    //Your code..
        
    $spawns $this->arenas["sw-1"];
        
    $spawnno = ++$spawns["increments"];
        
    $spawns $spawns[$spawnno."spawn"] ?? null;//1spawn, 2spawn... etc.
        
    if ($spawns === null) {
            throw new \
    OutOfRangeException("Spawn '".$spawnno."spawn' is not set in arenas. Could not teleport player to '".$spawnno."spawn'.");
        } else {
            
    $p->teleport($spawn);
        }
    }
    //When game ends, you will need to reset the increments by doing
    //$this->arenas["sw-1"]["increments"] = 0;
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Thank you but after player join arena he is teleported to waiting lobby where wait until game start and then is teleported to spawn so joinToArena function only add player to my waiting lobby
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.