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

Need help

Comments in 'Plugin Development' started by BlubberBoy333, Jul 23, 2015.

  1. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I'm developing a SkyBlock server, and so far everything is fine. Except for one thing.
    When the player creates an island it teleports them to a random world, then makes the island in that world, then teleports them to the island. But is doesn't teleport them to a ransom world, it just makes the island in the world that they are in.
    Here's some of the code
    PHP:
    $randLevel rand(19);
    if(
    $randLevel == or $randLevel == or $randLevel == 3){
        
    $sender->teleport(new Position(1010010$this->getServer()->getLevel("SkyBlock1")));
        
    $this->makeIsland($sender->getName(), $this->getServer()->getLevel("SkyBlock1"));
    }elseif(
    $randLevel == or $randLevel == or $randLevel == 6){
        
    $sender->teleport(new Position(1010010$this->getServer()->getLevel("SkyBlock2")));
        
    $this->makeIsland($sender->getName(), $this->getServer()->getLevel("SkyBlock2"));
    }elseif(
    $randLevel == or $randLevel == or $randLevel == 9){
         
    $sender->teleport(new Position(1010010$this->getServer()->getLevel("SkyBlock3")));
          
    $this->makeIsland($sender->getName(), $this->getServer()->getLevel("SkyBlock3"));
    }
    The idea is to teleport the player to the world first so they are in the world that the island is created in, then teleported to is. But it doesn't even teleport the player to the random world. Can anyone help?
  2. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I know, not the best way to get a random number
  3. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    use mt_rand instead of rand and do
    PHP:
    $sender->teleport($this->getServer()->getLevelByName("SkyBlock1")-> getSafeSpawn(new Vector3(1010010));

  4. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    If you want to get a random number use this:
    PHP:
    $numbers = array(123456789);

    $number $numbers[array_rand($numbers)];
    I use it for string randomising on my server.
  5. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    mt_rand Is better :3 Uses a different algorithm => Faster

Share This Page

Advertisement