0
\$\begingroup\$

The system is something like this:

highScoreDB || Validator || PlayerSession
---Database---||--Script---||----Game------

PlayerSession is an active game session, on finalizing a match, the game checks if highScoreDB is full, if full; compare the session's score with the lowest DB score and replace if its greater; if not full then just add the session score normally. Upon score submission, the game also sends some other data for the Validator.

The Validator checks if the score is legit by processing the extra data(match duration, key entities interacted with, etc); if the score is valid, then score is applied successfully; otherwise, it's rejected and the sent data is logged elsewhere(not relevant ATM).

The highScoreDB simply stores the data for retrieval by players.


Now I do not know how to make and where to stick the scripts as well as how to appropriately store the data. I'd appreciate any assistance on this matter.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

The components Validator and Database will have to be on a remote server. Trying to implement either in Unity would be a bad idea.

I would recommend to use the HTTP protocol for the communication between database and validator. The reason is that HTTP is very unlikely to be blocked by firewalls, that you can implement the endpoint using a webservice and that the Unity script can use the class WWWForm to send POST requests to it. The example uploads an image to a webserver. You would want to upload playername, score and the data you need to validate the score. Use WWWForm.AddField(string key, string value) to add the necessary data to your HTTP POST request.

There is a vast variety of technologies you can use to implement the validator. You can use anything which can be used to create webservices and communicate with a database backend. The options are so numerous, that it is difficult to give any recommendation. There is something for everyone available here. ASP (.NET or classic), JSP, PHP, Node.js, Django, Ruby on Rails, etc. etc. Just pick the tech you know or would like to learn.

The database should be a common SQL (or NoSQL, if you feel adventurous) database. The scoreboard would be one table (name, score, timestamp). But you also might want to persist the validator-data so you can retroactively catch cheaters when you add additional validations later.

\$\endgroup\$
-1
\$\begingroup\$

In your game level scene you should have the actual score. In the same scene you could have the script(s) that check your highscore and update it if the actual score is higher.

You could do this at the end of the game. For example:

public void GameEnd()
{
    if(PlayerSession.GetInt() < actualScore) //I don't remember if this is the correct syntax of player session.
    {
        //Do stuff here to update score
    }
}

Now you only call this method when the player has lost.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .