Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Anyone made a small multiplayer (network) game?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Anyone made a small multiplayer (network) game?
AMCerasoli
Member #11,955
May 2010
avatar

By a dedicated server I mean that... a dedicated server... ;D

a VPS is some kind of dedicated server too, but I don't have neither of two.

The thing is I don't want to pay 16 E/month for a dedicated server just to show an online score of my game (inside the game :D) which is going to be sold (hopefully) for just 1.99 E... so... I was looking the way to do this trow FTP or something like that... For that reason I was saying that the game should download all the file inside a determined path, compare if the current score (client) is better than those downloaded and if it's upload the file and overwrite the old one...

The file just contain a name and a score... and are saved like this: 1.dat , 2.dat , 3.dat etc...

I know that 1.dat contains the better score so if the client beat that score, the game sends a new 1.dat file overwriting the old one. This should be done constantly... But I know there must be a hide problem I haven't think much of it.

bamccaig said:

You should have to beat a high score to make the list, not just match it.

Yes I think I'm going to do that, it's the less controversial option.

Quote:

You could use a VPS instead, or your own desktop if it is accessible from the Internet

I can't because I have a dynamic IP, and I can't use No-IP or something similar.

Quote:

I'm beginning to think that you're currently using some Web space provided for cheap with only FTP access and no direct access to the server.

Oh Yhea 8-), I could use MySQL but that doesn't change anything.

Quote:

If that's too much then you're probably SOL unless you can convince somebody else with a server to spare you a database.

Quote:

I'm currently paying $11/month for a VPS with more than enough power for this.

Quote:

If that's too much then you're probably SOL unless you can convince somebody else with a server to spare you a database.

Quote:

I'm currently paying $11/month for a VPS with more than enough power for this.

Quote:

If that's too much then you're probably SOL unless you can convince somebody else with a server to spare you a database.

Quote:

I'm currently paying $11/month for a VPS with more than enough power for this.

Hm... I think I might have one ahahahahahaha....

Edit: I have a better Idea, to relieve the task of the game, I can just send the file (from the game) each time the player reach a new better score, this way I delete the possibility of hackings. Then from my computer I run another program which load the files and order them, and in the game show the first 12 but in the web page I could show all the people that have played my game! COOL!.

bamccaig
Member #7,536
July 2006
avatar

Oh Yhea 8-), I could use MySQL but that doesn't change anything.

That actually changes everything... If you have access to an Internet-accessible MySQL database (or server with MySQL and a Web-accessible Web server) then just use the database. :P It will work so much more reliably than any kind of FTP solution.

I have a better Idea, to relieve the task of the game, I can just send the file (from the game) each time the player reach a new better score, this way I delete the possibility of hackings. Then from my computer I run another program which load the files and order them, and in the game show the first 12 but in the web page I could show all the people that have played my game! COOL!.

I'd still opt for the RDBMS solution... That sounds like it will be very ugly and hard to manage. Imagine how unhappy your users will be if their awesome high scores aren't recorded properly. Especially if you make them pay for the game. :-X

AMCerasoli
Member #11,955
May 2010
avatar

bamccaig said:

That actually changes everything... If you have access to an Internet-accessible MySQL database (or server with MySQL and a Web-accessible Web server) then just use the database. It will work so much more reliably than any kind of FTP solution.

Hmm.. I didn't know that, thanks again man! I'm going to study that.

bamccaig
Member #7,536
July 2006
avatar

If you can't access the MySQL database from the Internet (i.e., it may only listen on the loopback interface) then you can always write a Web application interface using PHP, for example. Then just make simple HTTP requests to the server and have your PHP code process them. That, of course, depends on your server supporting PHP (or another server-side technology), but if you have MySQL then you almost certainly have PHP too.

AMCerasoli
Member #11,955
May 2010
avatar

I'll check out that, there is a way to know if their accept connection from internet besides talking directly with them?, there isn't another term besides loopback, you know they use to use more commercial words... Because at the moment I have no MySQL but if I want I can activate it(paying a little bit more)...

They have this:

Quote:

Aruba.it has also activated the offer for the MySql support: technically it is an DBMS (Database Management System) or rather, a management system for Database, practically it is a fast Database with high performance, that allows you to create dynamic websites with backend MySql.
The MySQL service offers a maximum of 5 databases and an overall disk space of 100Mb.

The service can be used only by domians hosted by our hosting services or Dedicated Servers. You can increase the disk space with (100Mb) additional packages of 100Mb each.

The predefinited interaction language is PHP, but it is possible, thanks to the MyODBC drivers, to interact with it also by ASP pages, too.

What do you think?

Oscar Giner
Member #2,207
April 2002
avatar

If you already have php there, you don't need a DBMS for such a simple task. Just store the scores in a file and use PHP to lock it when you want to update it.

Pseudocode:

$fp = fopen("scores.dat", "r");
flock($fp, LOCK_EX))
$score_array = read_scores($fp);
insert_score_submited_by_player($score_array, $POST[$score]);  // I don't actually remember how to acess post variables :P
write_score_file($fp, $score_array);
flock($fp, LOCK_UN);
fclose($fp);

[edit] Disclaimer: I omited error checking for simplicity :P

Thomas Fjellstrom
Member #476
June 2000
avatar

You can also use a SQLite or BerklyDB (bdb) database instead of mysql. Both are file backed, so you don't need a DB server.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

AMCerasoli
Member #11,955
May 2010
avatar

Seems great, but my hosting provider doesn't support SQLite, only MySql and Microsoft SQL server.

I have just a simple hosing service. For that reason I was talking about FTP, I'm going to study the PHP and HTTP possibility though, this is just to be able to offer an online table in-game at the first moment, but if the game success I might rent a VPS and use ENet and I would add another online options. Thanks.

Thomas Fjellstrom
Member #476
June 2000
avatar

Seems great, but my hosting provider doesn't support SQLite

Its a php module, you could probably upload it yourself and just use it. Same with BDB. Both are based on (more or less) simple files.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

Its a php module, you could probably upload it yourself and just use it. Same with BDB. Both are based on (more or less) simple files.

I doubt he could install the module if it isn't already installed. If he could then he could do a lot more than he's letting on. ;) Of course, there is a chance that the sqlite module is installed and just not mentioned by his host. There's also a small chance that he could convince his host to install the sqlite module.

ImLeftFooted
Member #3,935
October 2003
avatar

insert_score_submited_by_player($score_array, $POST[$score]);  // I don't actually remember how to acess post variables :P

It's $_POST or $_REQUEST if you don't care whether it's GET or POST.

Matthew Leverton
Supreme Loser
January 1999
avatar

Seems great, but my hosting provider doesn't support SQLite

Are you sure? It comes bundled with PHP5, and you'd have to explicitly disable for it not to work.

AMCerasoli
Member #11,955
May 2010
avatar

Yes I spoke directly with them, and they have no support for SQLite, and it seems it's going to be that way for a loooong time...

Well, actually I haven't but I saw a post in their web page but now seeing again they seems to have suport for SQLite... The problem was they took a lot of time to pass from 4 to 5 and the internet is plagued by people complaining... They have support for:

libxml
xsl
xmlwriter
dom
xmlreader
xml
wddx
tokenizer
session
pcre
SimpleXML
SPL
PDO
SQLite
standard
Reflection
posix
pdo_sqlite
pdo_mysql
mysqli    <--- WTF
mysql
mime_magic
mhash
mcrypt
json
imap
iconv
hash
gettext
gd
ftp
filter
exif
date
curl
ctype
calendar
bz2
bcmath
zlib
cgi
pdf
ionCube Loader

But know they're complaining why they don't support PHP-SOAP or something... I don't even know what it's and don't what to know to be honest :o

But I'm going to try to do what Oscar Giner suggested me, I'm going to use something like libCurl to send a request and process it.

Send the actual score of the player, if it's better run the script to erase the old one from the list (the file) and retrieve the "socres.dat" file, and if isn't just retrieve the "scores.dat" file anyway to keep the list actualized. Retrieving the list is what I don't know how to do it, I'm new in all this but I'm reading...

A library like libCurl should keep me away from sockets, headers and things like that, right?

Derezo
Member #1,666
April 2001
avatar

MySQLi is just a more enhanced version of the MySQL drivers that supports bindings and procedures and such.

I just recently started using CodeIgniter and am really liking it. They have a great community, as well.

"He who controls the stuffing controls the Universe"

AMCerasoli
Member #11,955
May 2010
avatar

And they have a lot of documents too, even videotutorials.

I have another idea... What if I set up a server on my machine, and constantly send my IP address to my current host server, then the game would connect to the host server read the file called something like "what_is_your_IP_now.dat" and then connect with my dedicated server at home...

:o

This way I could start learning ENet insted of PHP and libCurl ;D

ImLeftFooted
Member #3,935
October 2003
avatar

{"name":"Screen_shot_2011-04-14_at_1.17.58_AM.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/4\/0479217ec8bb51f3b851b05a7b598c9a.png","w":443,"h":566,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/4\/0479217ec8bb51f3b851b05a7b598c9a"}Screen_shot_2011-04-14_at_1.17.58_AM.png
Green are all the tracks that you can undo. Yellow is the last thing you placed, and therefore, the latest in the undo queue.

You add new track by touching and dragging. Just the beginning and end of the drag are used to calculate a run of track.

I'm going to work on the network code soon, once I get a bit more UI.

Here's a cropped full res shot:
{"name":"Screen_shot_2011-04-14_at_1.23.46_AM.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/9\/c9ce513d5293b68a0134253756252aa1.png","w":636,"h":404,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/9\/c9ce513d5293b68a0134253756252aa1"}Screen_shot_2011-04-14_at_1.23.46_AM.png

AMCerasoli
Member #11,955
May 2010
avatar

YHEAAAAA!!! Nice man!!!

Try to make it commercial, you know good graphics, sound, etc... That game has potential and being online even more.

You have the iPhone SDK? I'm starting to think that I'm the only one that don't have it...

TeaRDoWN
Member #8,518
April 2007
avatar

Wow, this thread took off like a rocket. Fun to see that I'm not all alone. :)

AMCerasoli
Member #11,955
May 2010
avatar

:) yhea... for each question you have I think there are at least 1.000 K people wondering the same...

I have checked again and no I have not SQLite, would be dangerous if I show people the result from phpinfo()?.

Vanneto
Member #8,643
May 2007

Not really, no.

In capitalist America bank robs you.

Thomas Fjellstrom
Member #476
June 2000
avatar

I have checked again and no I have not SQLite

That list you posted has pdo_sqlite in it. Its there. Note, it is not a SERVER based SQL system. No server required, just a simple bit of PHP code (or C/C++, or Perl, or Python) to access it.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

AMCerasoli
Member #11,955
May 2010
avatar

I don't know, that list was from another guy too... My PHP version is 5.2.12 check out this... http://62.149.131.186/ver.php

But there is no problem, I'm not going to use SQLite nor some database language, I don't need those features for such simple task. I could use the CGI too I think they allow be to upload binaries since I have a "cgi-bin" folder, but I'm going to use PHP.

Let's see. I still need to read a lot, there is a lot of people that say that PHP wins against the CGI but since I already know C++ I would prefer to use it, but I don't know...

Basically I don't know what I'm talking about ;D... So... I also found a guy asking the same question at gamedev.com and they recommended to use PHP:

Quote:

Quote:

I'm looking to setup a PHP script that will take a highscore along with some type of key to validate it. The application will then call the script and upload the highscores.

Or if there is any other solution available, that would be great. Maybe even running remote MySQL queries directly from the application....

No that would be less than ideal.

This is because the user would be able to detect the MySQL login / password and put in their own data, which would be bad.

Using a PHP (or even a CGI program written in C++, maybe, so it can reuse code from the app itself) script to update high scores, list servers etc, is definitely the way to go.

It's much easier to code this sort of high-score updater or server-list manager in PHP than it would be in C++ (well, if you know PHP anyway).

 1   2 


Go to: