Getting actual time

Get help using Construct 2

Post » Thu Mar 21, 2013 2:25 am

Hi everyone. I'm wondering if it's possible to get actual world time in a game and not just the system time on someone's machine or phone. This would protect against cheating in a time based grinder game.

Anyone have thought on how this could be done?
B
5
Posts: 2
Reputation: 1,304

Post » Thu Mar 21, 2013 12:23 pm

Perhaps there is some sort of plug-in or something (I didn't Check).
I'm currently only aware of how to do it in js.
   a clock example.
Could be more info in the JS sdk threads.
B
20
S
2
Posts: 257
Reputation: 2,431

Post » Thu Mar 21, 2013 2:24 pm

Look at system expressions under Time. tickcount gives you the number of ticks since the beginning of the game. You could also simply keep your own tick count in a global variable that get incremented every tick you want.

If you prefer to get a real "time" and not just tick count, use time instead of tickcount or keep a count of all dt in a global variable. Magistross2013-03-21 14:34:42
B
47
S
17
G
18
Posts: 847
Reputation: 13,827

Post » Thu Mar 21, 2013 3:12 pm

I'm pretty sure mhgames is looking for a way to pull real-world time into the game using a source other than the player's device.

Is it possible? Yes, but there's no simple way to do it from within the editor (unless someone's created a plug-in to do it). You'll need an external source containing the current date/time, and a method of pulling that data into the game at runtime.

There could very well be an easier method, but one option would be to set up a webpage using PHP to produce the current date/time, and using an AJAX request to pull that data into the game.zatyka2013-03-21 15:14:15
B
44
S
13
G
7
Posts: 338
Reputation: 10,389

Post » Thu Mar 21, 2013 4:30 pm

I don't think you need to fetch the real time from a remote server to actually prevent cheating. And for a time based game, the latency caused by the process of retrieving time from an external source usually is a no go.

Best to stick to tickcount and "dt count"... Not cheat-proof, but anyway, what is cheat-proof nowadays ? Magistross2013-03-21 16:36:25
B
47
S
17
G
18
Posts: 847
Reputation: 13,827

Post » Thu Mar 21, 2013 4:48 pm

@Magistross

You could very well be right about preventing cheating using other methods, but it really depends on the game.

Regarding latency, I didn't mean to suggest using AJAX server requests to constantly determine the in-game date/time. I was more thinking along the lines of a single AJAX request to determine the date/time upon loading finished or on the start of the first layout, and syncing the in-game clock to the request's result. At that point, in-game mechanics can maintain the correct date/time.zatyka2013-03-21 16:53:44
B
44
S
13
G
7
Posts: 338
Reputation: 10,389

Post » Thu Mar 21, 2013 5:10 pm

@zatyka

Of course, repeated AJAX requests is out of question. But syncing the game clock only once upon loading is not really helping to validate a timed high-score. You need two requests, for starting time, and ending time... so twice the latency. Depending on the game need, it might not be an option.

I guess combining both external and internal validation methods could work too. Compare external time with in-game time, and if results are too far apart (latency excluded), reject the high-score.
B
47
S
17
G
18
Posts: 847
Reputation: 13,827

Post » Thu Mar 21, 2013 6:26 pm

Based on the original post, I was under the impression that mhgames's goal was to ensure that a player waits for a certain amount of real-world time to elapses before an in-game action occurs (e.g. growing crops in farmville). I still believe my method would work in that capacity, thought there could be a much simpler way to do it that I'm not aware of.zatyka2013-03-21 18:30:05
B
44
S
13
G
7
Posts: 338
Reputation: 10,389

Post » Thu Mar 21, 2013 7:20 pm

Hmm, I thought mhgames meant players would have limited time to accomplish certain things.

Limiting actions by a real-world time delay could still be accomplished internally, but if the wait time can be done "offline" (e.g. growing crops in farmville ), then yes, some syncing has to be done !
B
47
S
17
G
18
Posts: 847
Reputation: 13,827

Post » Thu Mar 21, 2013 8:17 pm

I was hoping there was some way to do this too.

Hopefully it's something that will be possible in future updates.
B
35
S
6
G
2
Posts: 121
Reputation: 3,585

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests