How to increment data stored while player is offline?
Hi there, so I've been messing around with a prototype of mine that can store and retrieve data using MYSQL and Php. So far it's going good. so I have an issue that I've ran into where I have a data value that needs to increment over time even if the player is not connected to the server. Think clash of clans where the gold and other resources continue to increment even if the player is not in the app. Can I do this in code on Unity or is this something that will need to be coded in Php or JSON?
Thanks any help is greatly appreciated
Answer by BarleyWarb · Jan 10, 2017 at 06:19 AM
I would think that would be on the server side. You'd basically save the time when the player logged off, and then check the difference when the player logs in again. It doesn't really need to actively increment while offline (or it could need to in certain cases I guess). Instead, if the player is supposed to gain x gold every hour, then the next time they log in you would just update their gold by x * (currentLoginTime - lastLoginTime) or what have you. I suppose you could also save those values locally, but then they might be able to cheat by changing system time or editing the file.
At least that's how I would do it, but maybe someone here has a better idea :)
Thanks for your input! Yeah I'm definitely not going to store any values locally to avoid cheating and changing values. I'm new to multiplayer coding and networking in Unity. Can I code the server in Unity and update the values there?