Hello, i want to make system like in clash of clans to upgrade skills. Each skill may take days to upgrade. Do i use coroutine with timer on server side or how do i approach it? How do i save time if server restarts?
Just write down the start time, check during whatever heartbeat you have, when it unlocks, update the fact that it is unlocked.
Exactly, that’s how it works
Games like that usually are based on a website with a web backend which has a database in it’s back. Any actions that take a certain amount of time are simply entries in some kind of task list with an end / finish timestamp. Especially games with thousands of accounts would not constantly update and run the logic on the server for every single account. They usually lazy update whenever necessary. This also includes things like resource generation and stuff like that. When queried the server simply calculates what should has happened since the last update. If for example a resource generating building is upgraded and that finished somewhere in between, the calculation would simply be a 2 step update. How many resources has been produced since the last update and the time the building upgrade finished and another one with the new production rate from the upgrade finished point to the current time.
When you have several hundred thousands of players it just makes no sense to forcefully advance all those players every second or minute. MMOs like this work completely different from other games.
What is hearthbeat, im new to coding
Well, I think it’s pointless to explain it in any more detail as we don’t know what kind of networking you’re using. So the best source would be Heartbeat (wikipedia).
Thanks ill look at it, it just coding single player version of the game for now. But in future i plan to use unity netcode for entities