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

Random Global Spawn

Discussion in 'Requests' started by PogzNet, Aug 24, 2018.

  1. PogzNet

    PogzNet Spider

    Messages:
    8
    I cant seem to find any plugin that sets random global spawn automatically. I know I can set it manually but im thinking of randomizing a global spawn given a set interval and a scope. (ie random number from 0 to x, 0 to Y, z remains fixed to avoid dropping from a high place) for every 30 minutes.

    I saw that this might probably be the class which can be used https://github.com/pmmp/PocketMine-...ine/command/defaults/SetWorldSpawnCommand.php but if anyone has the free time to write a simple plugin like that it would be great.

    The rationale behind this is that a lot of people are huddling around the default spawn point. As much as possible, I would like new players to be randomly thrown into locations so that players would not be clustering around the same location.
     
  2. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    ;) I will take your request
     
  3. RumDaDuMCPE

    RumDaDuMCPE Witch

    Messages:
    67
    GitHub:
    RumDaDuMCPE
  4. PogzNet

    PogzNet Spider

    Messages:
    8
    Documentation doesnt contain any mechanics. "Randomly teleports players when they join." is a bit vague. Teleport NEW players? Teleport all players? How random _is_ random? Like within 1000x1000 blocks away?
     
  5. PogzNet

    PogzNet Spider

    Messages:
    8
    Thanks! Let me know if you need me to test it!
     
  6. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    Oh no! I accidentally deleted the plugin file (its 1 month ago and i forgot the project) :v. Sorry it seems I can't accept xD
     
  7. PogzNet

    PogzNet Spider

    Messages:
    8
    Aw thanks. :(
     
  8. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    Maybe i will try again with Github, so no 'accidentally deleted'
     
  9. PogzNet

    PogzNet Spider

    Messages:
    8
    I checked your code, im wondering if the doFirstSpawn is a valid trigger to recognize that its the first time a player logs and and should teleport randomly?
     
  10. PogzNet

    PogzNet Spider

    Messages:
    8
    Rums code seems to be straightforward. Does the checks and balances and has the 1000x1000 range. Im just trying to figure out how to only trigger this on first spawn. (and not randomly teleport returning players)
     
  11. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    When spawnpoint reset?
     
  12. PogzNet

    PogzNet Spider

    Messages:
    8
    More like, ifFirstSpawn, spawn to random location. but looks like theres no way to check if its the first spawn.
     
  13. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    Check first spawn? I think this method can be used?
    On player join, it will read to a data (yml, ...) if the player data is unavailable it will write like this:
    Code:
    playername : 0
    0 : not the first join
    At the same time it will run any function:
    PHP:
    public function onJoin(PlayerJoinEvent $event){
    $player $event->getPlayer();
    $cfg = new Config(//bla bla bla :v);
    if $cfg->get($player) == null{
    $cfg->set(//bla bla bla);
    //And save i dont learn that xD
    }}
     
  14. PogzNet

    PogzNet Spider

    Messages:
    8
    Did i understand correctly that your logic works like this:
    1.) Get player identity
    2.) Check config if player is equal to null (new player)
    3.) Set config value (marking that the player is no longer new)
    4.) Run teleport snippet
     
  15. RumDaDuMCPE

    RumDaDuMCPE Witch

    Messages:
    67
    GitHub:
    RumDaDuMCPE
    I've added your requested feature.
    Now only new players will be teleported.
    Check the GitHub Repository.
     
  16. RumDaDuMCPE

    RumDaDuMCPE Witch

    Messages:
    67
    GitHub:
    RumDaDuMCPE
    Why not just use PlayerClass->hasPlayedBefore()?
    https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/OfflinePlayer.php#L118-L120
     
    PogzNet likes this.
  17. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    RumDaDuMCPE likes 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.