I am currently working on a RTS game. Where an empire gets resources based on the system time of which the game is running. The problem is that, if you change the system time forward. The resources boom up instantly when the game is run again. Again, I've played this game on my iPad, Injustice: Gods among us. If you turn up the time, your energy is restored back and you can play without waiting for your energy to replenish. This type of hacking is very easy and also annoying for big companies. A game made by such a big company has so many flaws. How can I implement a flawless time based game and overcome this problem? I've read this post too, but I haven't got any perfect answers.
2 Answers
There is no proper way without communicating with other devices on the internet. If big companies can't solve a problem which is costing a lot of money, then there is no way in solving it in a restricted environment of GM.
Your best bet has been mentioned in your linked post: Get the time somewhere else. One way would be creating a small tool you can run on a server which does nothing else than returning a system time.
Another way would be punishing such cheats by removing the resources earned if the time is set back, even allowing negative values.

- 67
- 1
- 8
As an expansion Gemoron's post about internet access, I recently discovered a way to obtain data from the internet in Game Maker.
There is a tiny little free, open source program called WGet you can use. I simply run it in code from GM8 (Studio cannot do this) through a VBS script that causes it to run individually, and it saves the data from the link you give it in the working directory.
You execute the program, and put it in a wait loop (with a timeout escape), and when the file exists, you open it as a text file, read the line into a variable, close and delete the text file, and then return the variable containing the string.
Once the script is built, it takes a total of one line to retrieve the information.
time=getOnlineData("http://www.example.com/path/to/data")
You would, of course, require internet connection, need to allow the WGet program through your firewall. I have used this to great effect, and it works wonderfully. I haven't tested with larger files, but 500B files are done and the string loaded in a fraction of a second in my tests.
So, you'd just run this script on a webpage that keeps the time (and just the time), and then parse the time into a way that you can use in the game.
So, you could have it down to:
//Get game start time from previously saved file.
startTime=getStartTime()
//Get current time from site
currTime=getOnlineData("http://whatsthetimemrwolf.com")
//If it is in standard javascript date format, it's easy from here. Subtraction gives the time passed in milliseconds.
passedTime=currTime-startTime
Easy when you have the system set up. As a warning, the start time could be altered in the save file, but a simple encryption process built into your game should prevent any tampering.
Goodluck, and happy programming. :)

- 27
- 6