Sign in to follow this  
Agemaniac

Multiplayer Game - Help

Recommended Posts

Hi. I really dont know how to google this problem so, im asking here. I will be implementing a game that keeps a ranking (showing in a web page or something like that). So, two or more players will be connected with a software (not a web game, flash game). My question is, does the clients need to be connected to a server like in BattleNet? and...how can i set Up a server? I mean, any computer that have a conection with NET and is always ON can be used as a SERVER? Why cant the clients just send a packet in the end of the game to the server that says who wins the game? Any resources, articles,links, advice will be great. sorry about the poor english and the basic question. Thanks.

Share this post


Link to post
Share on other sites
it's not a web game, but a flash game?

well - you can just use PHP and a MySQL database, write a PHP script which gets two parameters: a username and a score, and then "request" the php script from your game.

i.e.

http://myserver.com/save.php?name=chris&score=50000

of course you should add some security, i.e. by encrypting username and score.

whatever you do, your clients don't have to be connected during the whole game. if they just submit the score, then it makes sense if they connect to the server after the game is over, then submit the highscore, and then close the connection. in this case a php script as above would work fine.

any computer with an internet connection can be used as a server.

Share this post


Link to post
Share on other sites
Hum..no its is not a flash game...it is a 3D game/software..think in it like Warcraft III (more simple, of course). So, when the clients get into the game (that just can be played online) they have to connect to the server (i think). I need information about how can i set up this server? does i need a special service or just internet connection...does i need a special software? and witch approach i should use in the 3D game..

Share this post


Link to post
Share on other sites
All a server is, is a computer with an internet connection. Its usually always on. For example, I have a PC sittign next to me just now that is running Apache, and I use that to run my website.
If you want a way to just submit and/or view scores, you just need to write a program that runs on the server. This program will listen on a port, and when it gets a connection it'll read a command. Depending on the command, it will either store the score in a database (which could just be an array in memory, or it could be a file on disk (or both)) or reply with a list of scores.
Your client program then just need to connect to the program on the correct port, and send the appropriate command.
If you want to use PHP and go the web way that crupp suggested, look into HTTP requests. Its pretty simple to do. You'll need a web server (Such as Apache or IIS ([evil])), PHP installed, and probably MySQL or some other database server.
You could even combine the 2 methods and make your server program write to a MySQL database, and have the PHP script read from it to display the scores.

What exactly do you mean by 'server'? Theres 2 definitions - 1) A computer connected to the Internet running programs 2) The program running on the computer. You can run a server program on a PC with no Internet connection too (but it'll only be able to receive connections from the PC itself).

Share this post


Link to post
Share on other sites
Hi, thanks for the reply. By "server" i mean a computer connected to the net running a program (the game, in a dedicated way). If you guys, was going to implement a game that keeps track of a ranking, witch approach would you use?
it seen to have two:
Pay for a server (that is a little expensive) and run the game server in there.
Pay for a internet host (dont know really how to say this) that is usually paid by MB/month transfers. In this case the clients use the web page to saw who is online and share IPs or something that launch their game. so, in the end of game (clients connected p2p) the client send a packet of information to the server that receive it and add it to the ranking.

humm..thinking again now, is there some kind of software that already do all this stuff?

Share this post


Link to post
Share on other sites
The X-box LIVE! SDK does this already, but that doesn't help you if you're on PC.

I know that Gamespy.net has libraries (and services) that can do this for you.

If I were to implement it myself, I would probably make the score keeping be HTTP requests that can go to a PHP script somewhere. The question is how you find that "somewhere" -- If you know that you will have a reasonable host, you can use DNS. "scores.mycompany.com" would go to the server, and the hard-coded URL "/scores.php" would be the script, for example.

There's a separate issue of security. Basically, users will hack your system and submit unauthentic high-scores. Just live with it, there's nothing you can do to stop a sufficiently motivated hacker.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this