24/7 server side generation of ingame currency

Hello,

I’m currently developing a PC game in C# where you instantiate buildings to a terrain to build your own village. That works fine so far.

My problem: I would like to give those buildings different, specific tasks, e.g. building 1 is a bank and generates money (e.g. 100 money units per hour) which is used to build/ upgrade other buildings. But I would also like the bank to generate money while the player is offline. So I need something like a 24/7 online server that generates the money and the playerclient just gets this value from the server. This way I also prevent cheating, because the important stuff is handled not on the players local PC. I also thought about a register/ login system in future.

How can this be achived in the easiest way ? I don’t think SQL databases can e.g. add a certain amount of money/ units to a specific playeraccount every hour, or do they ?

Thank you for reading!

I don’t think SQL databases can e.g. add a certain amount of money/ units to a specific playeraccount every hour, or do they ?

You can either have your database do that for you by a query statement or in your server code, you could have a loop for every X minutes to send a query to the database that would update their money based on their production amount. I know this is possible but for the syntax on how to write it, google that as I don’t know your database.

You could also just save their log out and log in times, and when they log in - update their money based on the logout and login time and their production amount.