How to get server time and record playing duration?

hello guys
i want to know how can i get an server time? i use “Firebase::ServerTimestamp()” i get this answer
Screenshot 2023-01-28 164011
i want to setup playing duration for each user and i don’t want use local storage for prevent cheating

i need guide how to get time from firebase or any server correctly , and then how to do some mathematics on time to calculate total spend time?

thanks in advance

any idea?
dear @Gruk , @arthuro555

Please do not mention random people to get attention, that is bad etiquette and will rub people the wrong way.

Firebase::ServerTimestamp() is not a function to get a timestamp from the server. It’s a special value you can set a Firebase document’s field to, to tell Firebase to replace it with a timestamp from their servers.

1 Like

of course dear arthuro555 ,thank you

is there any way to measure playing time for each user?

Simply use a timer for that (and store it in Firebase if you want to prevent cheating).

1 Like

thank you dear @Gruk

Hello, I want to track how long since a game has started. I want this to continue tracking even if the player is offline. I figured I’d do some sort of calculation like current time - stored time. I’m not sure I understand how to get current time from firebase (I need to prevent cheating). Additionally, what is th best way to store the time from firebase while optimizing data usage? Thanks in advanced.

I am that one guy that will do something if i want to
But mostly because you are trying to prevent me from doing it
You disable auto-jump?
I will use controller with auto-fire or 3rd party software like AutoHotKey to spam jump button
You will hide values by making mirror values?
I will sit until i find correct ones and that is pretty easy with software like Cheat Engine
You want to check if i messed with time on my device?
I will find how your game is checking it and will insert wrong data
Or better yet why to bother?
I will find values for items i want and will give tons of them to myself

My point is
YOU CAN NOT stop me or any1 from doing something
You can only make it harder to achieve
Even if your game would check every frame for current time from some online source
It would take few mins to google how to duplicate items in mobile or desktop game

You will never be 100% secured from cheaters
I would consider how much you need it
If you are going to make money on your game then i say yes try your best to shove in any anti cheat measure you can come up with
If you are making free game i would question is it worth the effort

And again keep in mind you are not preventing something from being done
You are only making it harder to be done

Very good points. Once completed I plan on having a monthly subscription for full features. I found a way to get the time from the database although it was not easy… I used the firebase time stamp feature, referenced the child variable that equaled the time stamp, then filtered the result using javascript so I was left with the current server time in seconds. Im sure there was an easier way but it works for me. My app will basically pair two people. it will be marketed to couples so i don’t think they woudl go too far out of their way to cheat but I could see people changing the device time to try and speed up the game and that would cause a ton of problems due to the nature of my game.

1 Like