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

Started by GeantPiste on

Topic category: Help with Minecraft modding (Java Edition)

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 ? 

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.

Joined Apr 2024
Points:

User statistics:

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