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

Started by GeantPiste on

Topic category: Help with Minecraft modding (Java Edition)

Active 1 year ago
Joined Apr 2024
Points:
98

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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 ? 

Active 1 year ago
Joined Apr 2024
Points:
87

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1
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.

Active 1 year ago
Joined Apr 2024
Points:
98

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
Thanks a lot ! But won't…
Wed, 04/24/2024 - 12:06

Thanks a lot ! But won't this cause lag if there are too many players ?