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.
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?
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
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?
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)
More like, ifFirstSpawn, spawn to random location. but looks like theres no way to check if its the first spawn.
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}}
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
I've added your requested feature. Now only new players will be teleported. Check the GitHub Repository.
Why not just use PlayerClass->hasPlayedBefore()? https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/OfflinePlayer.php#L118-L120