Advertisement
Skylinerw

@EnderCreeper132 - 1.8 Detecting consecutive logins

Sep 16th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. The "stat.leaveGame" objective-type will be necessary. The main problem is the first time the player logs in, they will not have that score set to 1, so a secondary objective is needed to track that. Teams could be used in place of a secondary objective, but would prevent or hinder the use of teams elsewhere.
  2.  
  3. PREREQUISITES
  4.  
  5. 1. Objective that increases a player's score by 1 when they leave the game. Once they return, we can target them based on their score.
  6.  
  7. /scoreboard objectives add LeaveGame stat.leaveGame
  8.  
  9. 2. Secondary objective used for the purpose of tracking first-time logins.
  10.  
  11. /scoreboard objectives add FirstLogin dummy
  12.  
  13. CLOCK COMMANDS
  14.  
  15. The following must be run in numerical order.
  16.  
  17. 1. Adding 0 to all player's "FirstLogin" score. Since players are not automatically tracked on the scoreboard, this is necessary. It will not change the score players had previously, but those that were not tracked will be inserted into the scoreboard with a default score of 0.
  18.  
  19. /scoreboard players add @a FirstLogin 0
  20.  
  21. 2. Players that have a "FirstLogin" score of 0 means they have never logged in previously. As such, we'll use that to change their "LeaveGame" score to 1 for the sake of simplicity.
  22.  
  23. /scoreboard players set @a[score_FirstLogin=0] LeaveGame 1
  24.  
  25. 3. And then we'll set that player's "FirstLogin" score to 1 to prevent future detection of the previous commands.
  26.  
  27. /scoreboard players set @a[score_FirstLogin=0] FirstLogin 1
  28.  
  29. 4. It's at this point you run any commands you like. These commands will target players who have a "LeaveGame" score of 1.
  30.  
  31. /say @a[score_LeaveGame_min=1]
  32. /scoreboard players add @a[score_LeaveGame_min=1] LoginAttempts 1
  33. /execute @a[score_LeaveGame_min=1] ~ ~ ~ summon Creeper
  34.  
  35. 5: After those commands run, you'll set their "LeaveGame" score to 0 to prevent constantly affecting those players.
  36.  
  37. /scoreboard players set @a[score_LeaveGame_min=1] LeaveGame 0
  38.  
  39. CONCLUSION
  40.  
  41. From that point onward, players would have a "LeaveGame" score of 0, meaning the mechanism will not target online players a second time. That's where the "stat.leaveGame" objective comes in: once a player logs out, that score will increase by 1 on its own. That way when they log back in the mechanism will target them again. After the very first login, only command blocks 4 and 5 will have functionality. 1-3 are required for first-time logins.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement