I'm making a turn based game, They player can buy power ups in a store and then use it in the game. I imagine I need to store the power buyed in a database and, when the player clicks to use it in the battlefield, the server checks if this player has this power. Is this right? I don't want to store it on the client side because people can hack it. Is this the correct approach?
The player, when hits, fills a mana bar. When the mana bar is full, can unleash a power (different than the previous example). For this, I though of storing the mana bar value for each player (is just 1vs1) in the server side and when the player wants to unleash this power, the server checks if the mana bar is full. Is this correct or I'll consume a lot of memory?
Control user actions from server
Re: Control user actions from server
Hi
Yes, this sounds like the best way.
There's an improvement I could suggest. I would keep the player's power ups in memory when the User is online, to avoid hitting the database each time the player wants to use an item. Accessing data in memory is much much faster.
So the idea would be that when the player comes online you load his inventory from the database in memory.
You then apply any changes (add/remove stuff) in memory
When the user disconnects you store his inventory back to the DB.
Yes, it's the proper way to do it.
The mana bar can be represented by a number ... e.g. an integer from 0 to 100 (or so).
Definitely not a concern in terms of memory!
cheers
DarkSlash wrote:I'm making a turn based game, They player can buy power ups in a store and then use it in the game. I imagine I need to store the power buyed in a database and, when the player clicks to use it in the battlefield, the server checks if this player has this power. Is this right? I don't want to store it on the client side because people can hack it. Is this the correct approach?
Yes, this sounds like the best way.
There's an improvement I could suggest. I would keep the player's power ups in memory when the User is online, to avoid hitting the database each time the player wants to use an item. Accessing data in memory is much much faster.
So the idea would be that when the player comes online you load his inventory from the database in memory.
You then apply any changes (add/remove stuff) in memory
When the user disconnects you store his inventory back to the DB.
The player, when hits, fills a mana bar. When the mana bar is full, can unleash a power (different than the previous example). For this, I though of storing the mana bar value for each player (is just 1vs1) in the server side and when the player wants to unleash this power, the server checks if the mana bar is full. Is this correct or I'll consume a lot of memory?
Yes, it's the proper way to do it.
The mana bar can be represented by a number ... e.g. an integer from 0 to 100 (or so).
Definitely not a concern in terms of memory!
cheers
- coolboy714cp
- Posts: 323
- Joined: 06 Feb 2010, 02:45
- Contact:
Re: Control user actions from server
Lapo wrote:HiDarkSlash wrote:I'm making a turn based game, They player can buy power ups in a store and then use it in the game. I imagine I need to store the power buyed in a database and, when the player clicks to use it in the battlefield, the server checks if this player has this power. Is this right? I don't want to store it on the client side because people can hack it. Is this the correct approach?
Yes, this sounds like the best way.
There's an improvement I could suggest. I would keep the player's power ups in memory when the User is online, to avoid hitting the database each time the player wants to use an item. Accessing data in memory is much much faster.
So the idea would be that when the player comes online you load his inventory from the database in memory.
You then apply any changes (add/remove stuff) in memory
When the user disconnects you store his inventory back to the DB.The player, when hits, fills a mana bar. When the mana bar is full, can unleash a power (different than the previous example). For this, I though of storing the mana bar value for each player (is just 1vs1) in the server side and when the player wants to unleash this power, the server checks if the mana bar is full. Is this correct or I'll consume a lot of memory?
Yes, it's the proper way to do it.
The mana bar can be represented by a number ... e.g. an integer from 0 to 100 (or so).
Definitely not a concern in terms of memory!
cheers
What if the user modifies the client so that the items never disappear (or if possible in the op's game, increases the item count rather than losing it), and then disconnects? Wouldn't the modified values be sent to the database at that time?
SFS-Tutorials: http://sfs-tutorials.blogspot.com/
- coolboy714cp
- Posts: 323
- Joined: 06 Feb 2010, 02:45
- Contact:
Re: Control user actions from server
Unless you're talking about storing the information on the server's memory, if it is stored on the client, I don't see how you could protect against modified data.
SFS-Tutorials: http://sfs-tutorials.blogspot.com/
Re: Control user actions from server
Yes, of course, I'm taking about storing information on server! Everything stored on client can (and will be!) hacked.
Who is online
Users browsing this forum: No registered users and 53 guests