How to check the number of hours played by a player ?

Started by GeantPiste on

Topic category: Help with modding (Java Edition)

Last seen on 19:53, 23. Apr 2024
Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to check the number of hours played by a player ?

Hello, I'm creating a mod where I want to add custom advancements. So I want to give an advancement to any player who played 100 hours. I don't know how to get player's statistics and i didn't find anything helpful on internet. Can someone help me please ? 

Last seen on 20:30, 23. Apr 2024
Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello, first create a…
Tue, 04/23/2024 - 20:30

Hello, first create a variable that applies only to the player, then you need to create a procedure that triggers every tick of the player. In the procedure, add 0.05 to the variable (since there are 20 ticks in one second, hence 0.05). As a result, you have a variable that counts the game seconds for each player. From there, you can work with it however you like.