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

Random Spawn

Discussion in 'Plugin Help' started by ProfessorSlimez, Jan 28, 2021.

  1. ProfessorSlimez

    ProfessorSlimez Creeper

    Messages:
    4
    GitHub:
    ProfessorSlimez
    I need a plugin that randomly teleports players in a 1000x1000 radius when they die or when they first log in if you could help that would be amazing
     
    Primus likes this.
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    damn
     
    Primus likes this.
  3. ProfessorSlimez

    ProfessorSlimez Creeper

    Messages:
    4
    GitHub:
    ProfessorSlimez
    yeah i know im tryna make a anarchy / survival server
     
    Primus likes this.
  4. Trxgically

    Trxgically Spider Jockey

    Messages:
    26
    GitHub:
    trxgically
    I made a plugin just like this and is currently in the works of being submitted to poggit https://poggit.pmmp.io/ci/Trxgically/RandomSpawns/RandomSpawns
    This is the YouTube video on how to use it expect updates and stuff like that soon.
     
    Primus likes this.
  5. ProfessorSlimez

    ProfessorSlimez Creeper

    Messages:
    4
    GitHub:
    ProfessorSlimez
    Omg thanks I appreciate it so much
     
    Primus and Trxgically like this.
  6. Trxgically

    Trxgically Spider Jockey

    Messages:
    26
    GitHub:
    trxgically
    If you have any plugin ideas or suggestions or any help with my plugins my discord is N̶o̶T̶ ̶A̶ ̶B̶o̶B̶#5824
     
    Primus likes this.
  7. ProfessorSlimez

    ProfessorSlimez Creeper

    Messages:
    4
    GitHub:
    ProfessorSlimez
  8. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    The code also teleports players inside of blocks, and we don’t want that, do we? Just save the xyz in a pos and do a safespawn instead of Floor+2
     
    Primus likes this.
  9. Trxgically

    Trxgically Spider Jockey

    Messages:
    26
    GitHub:
    trxgically
    I know that is a bug I haven't gotten to yet and I don't know what you meant by "Just save the xyz in a pos and do a safespawn instead."
     
    Primus likes this.
  10. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Something like this...

    PHP:
    $spawn $level->getSafeSpawn();
    $coordX rand($spawn->$firstX$spawn->$secondX);
    $coordZ rand($spawn->$firstZ$spawn->$secondZ);
    $sender->teleport(new Position(rand(0,1) == ? -$coordX $coordZ$this->getLowestBlock($levelround($coordX), round($coordZ)), rand(01) == ? -$coordZ $coordZ$level));
    Function getLowestBlockAt()
    PHP:
        public function getLowestBlock(Level $level$x$z) : int{
            if(!
    $level->isChunkLoaded((int)$x, (int)$z)){
                return 
    128;
            }
            
    $chunk $level->getChunk($x >> 4$z >> 4);
            
    $x &= 0x0F;
            
    $z &= 0x0F;
            for(
    $y 0$y 128$y++){
                
    $block $chunk->getBlockId($x$y$z);
                if(
    $block !== 0) break;
            }
            if(
    $y != 128){
                return 
    $y;
            }
            return 
    128;
        }
     
    Primus and Trxgically like this.
  11. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Primus, Trxgically and minijaham like this.
  12. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Yes, others’ works are great examples you can look for.
     
    Primus and Trxgically like this.
  13. Trxgically

    Trxgically Spider Jockey

    Messages:
    26
    GitHub:
    trxgically
    Thank you I will be updating the plugin soon.
     
    Primus and minijaham like this.
  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.