Control user actions from server

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

DarkSlash
Posts: 30
Joined: 12 Feb 2016, 18:15

Control user actions from server

Postby DarkSlash » 16 Feb 2016, 16:47

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?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Control user actions from server

Postby Lapo » 18 Feb 2016, 09:09

Hi
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
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

Re: Control user actions from server

Postby coolboy714cp » 02 Mar 2016, 09:02

Lapo wrote:Hi
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



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?
User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

Re: Control user actions from server

Postby coolboy714cp » 02 Mar 2016, 09:06

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.
DarkSlash
Posts: 30
Joined: 12 Feb 2016, 18:15

Re: Control user actions from server

Postby DarkSlash » 02 Mar 2016, 14:06

Yes, of course, I'm taking about storing information on server! Everything stored on client can (and will be!) hacked.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 53 guests