Sign In Register

How can we help you today?

Start a new topic
Answered

How to use GS_MINUTE ?

Greetings,


How can I use GS_MINUTE?


I want the player to add 1 energy point per minute whether they are online or offline, so I tried to add Spark.getPlayer().credit("Energy", 1) to GS_Minute.


But it didn't make any difference.

 

I don't know what I missed. 


Please help me. >< 


Thank you.


Best Answer

GS_MINUTE is called by the server every minute and not for every player.

Beside you shouldn't update every players data every minutes. That is a very bad practice, Instead saved the date your energy was last updated and next you get the energy details, compute the difference in time to know how much energy was gained.


Answer

GS_MINUTE is called by the server every minute and not for every player.

Beside you shouldn't update every players data every minutes. That is a very bad practice, Instead saved the date your energy was last updated and next you get the energy details, compute the difference in time to know how much energy was gained.


1 person likes this

That's the unix timestamp.(or epoch). The number of seconds since January 1st 1970. You can look it up on google.

Either way, it is better to set your own date in the private data instead of the LastSeen once. You compare the date you save with the date from the server (new Date()).



1 person likes this

This is the case, that is, each time the player logs in, I need to record the time they log in, then start running the energy point, then when they next log in, I can calculate the elapsed time.


But when I use: Spark.getPlayer().getLastSeen().

What I got was $numberLong: "15XXXXXXXXX" a long list of numbers, is this? 


Can I have a better way to get time?

 

Thank you very much.

I fully understand .


Thank you very much for your guidance.


Thanks.   :))

Login to post a comment