Has anyone successfully created a visual server finder (like those present in many FPS's). I want players to be able to join the server across internet. It would need to search for servers and display them so that users could click and join.
Examples include the Halo or Swat 4 or CS servers.
I don't want to hear about cost or size or server limitations. I just want to know if anyone created one.
If you did, could you explain how. Thanks.
You don't actually "search" the internet for other players. When a user creates a session, you need to have that session store it's info in a database on YOUR own server. Then when a user searches for available sessions, they query the database for hosts (title of session + ping rate + etc). Then they select one, you get the info they need from it (IP address).
Posted By: khanoftruth
Re: Server search? - 02/26/07 05:44
I see. Did you create said visual database log? Or just theoretical (means I have to make it from scratch).
You have to make it...
Check out the MySQL thread in the user contributions... This will allow you to read/write to your database.
Posted By: Excessus
Re: Server search? - 02/26/07 14:59
I've made such a system for a client once.
What I did was create a few php scripts that fetch the list of servers (with an optional selection, like only deathmatch games), add a server to the list, remove a server from the list (note that you will also have to put in a timeout for servers that 'forget' to remove themselves from the list.
Then just run those scripts on a webserver with a database and call those webpages from c-script with the GSHTTP plugin (search for it).
If you go with the MySQL plugin, make sure you give the database user only the privileges it needs, because the MySQL plugin sends entire queries to the server. A hacker might send a query that corrupts your database. If you use the php approach, you can disallow TCP traffic for your database, so that only the queries that are created by your php script can be executed (still have to be carefull with SQL injection then!).
Posted By: Excessus
Re: Server search? - 03/04/07 12:27
I used MySQL. A flatfile system should work fine aswell (don't see any disadvantage unless the load becomes very high). I chose to go with MySQL because I knew SQL but not php at that time, so this seemed the easyest. I still think building SQL queries is easyer than "file fidling".
You should store the datetime in a column and remove those rows who where created more than x seconds/minutes ago, where x is either a static number or a setting that the client can be set within some range by the client. There are datetime compare functions in SQL databases, but for your flatfile system I would just use the system time and count seconds/minutes.
The problem is probably WHEN to do this removal. To always get an up to date list, you must remove all outdated rows before retrieval. In your case, you'll have to check all the rows and remove all outdated ones and then return the rest.
If you expect a very high load on this server, a more efficient but less accurate solution is to only remove rows once every x retrievals (use a counter). You can probably also remove outdated rows periodically, without client interaction but I don't know how.
To improve on this system, you could add a php file that removes a certain client at any given time and let the game server (not the central server) call this when it cancels the game. This does raise security concerns (anyone can use this php file, even from a browser, with any parameters) so you might want to add a random password that is decided by the game server when it joins.
You could also add a way to 'report' crashed/disconnected game servers. If you try to connect to a server from the list and it doesn't work, report that to the central server. The central server checks if it indeed can't connected and removes it if it really crashed/disconnected.
Good luck
Posted By: fastlane69
Re: Server search? - 03/04/07 16:34
I don't know php but we've been using MySql for close to a year and I have to say it is the way to go. The MySql plugin is great (has a small memory leak but nothing major), MySql is free, and it's actually easy to setup and use!
Not adding much to the discussion here except to say that if you can, take the time to play with MySql and use it instead of a flatfile system whenever you can... whatever time you spend learning it will pay off in droves in the future in terms of lowered development times and increased performance.