- Home /
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!
Answer by juicyz · Aug 26, 2016 at 04:47 AM
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.
@juicyz thank you! Which database and/ or server configuration would you recommend ? I have never done something like that (networking, databases, setting up servers). Where can I put the server code to ? When I set up a unity server in a C# script attached to a GameObject, the server will be deleted as I close the game right ?
I would like into something like $$anonymous$$YSQL using SQL or possibility $$anonymous$$ongoDB for NoSQL. I would compare the pros and cons and see which ones are the best for you.
I have never done multiplayer or SQL for a Unity Game yet so I couldn't tell you about that. That could be another question you ask here.
Your answer
Follow this Question
Related Questions
Is there anyway to use WebGl on a website without having users install a plugin? 0 Answers
Tanks!!! online question 2 Answers
Can I code the connection of my game to SQL Server the same way I would do with a web application? 0 Answers
mssql Integrated Security login failed 0 Answers
how can i use OnPlayerConnected ? 0 Answers