Vanilla 1.8 detect new player

Vanilla 1.8 detect new player - Free stock photo of action, adult, athlete

In vanilla 1.8 using command blocks, is it possible to change a player's spawn point after they first join a server?

When a player first joins a server they are in location "A" When they press a button to leave the spawn point (or use any other trigger) they are sent to location "B" If they die after leaving the spawn they will respawn in location "B"

No mods or plugins 1.8 Vanilla McEdit map editing is OK



Best Answer

This is one of the cases where using stat objectives on a scoreboard comes in handy, since it is impossible to detect players who don't have a score (i.e. a score of NULL, which is different from a score of 0!). stat objectives increase automatically depending on player actions, making them ideal for this. Set up a timePlayed objective like this:

/scoreboard objectives add timePlayed stat.playOneMinute

Contrary to the name, playOneMinute objectives increase at every game tick (making the value 1200 after one minute). You can use this objective to detect new players using @a[score_timePlayed=1].

To teleport new Players to a fixed point, set up a setblock clock and have it run

/tp @a[score_timePlayed=1] x y z

where x y z are the coordinates of your spawn.

Credit goes to /u/Boxfigs on reddit.


Should you want to re-declare an existing player as new (e.g. for testing), you can use

scoreboard players reset P timePlayed

where P is any valid target selector.




Pictures about "Vanilla 1.8 detect new player"

Vanilla 1.8 detect new player - Young Woman Leaning on a New Car at Car Dealership
Vanilla 1.8 detect new player - Young Woman Touching a New Car at Car Dealership
Vanilla 1.8 detect new player - White and Pink Floral Textile





Detect what the player types! (Vanilla) NEW 1.8 [Password]




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: David Morris, Gustavo Fring, Gustavo Fring, Tara Winstead