setup a php master server

i know this is a weird question, but can someone explain to me how to set up a php master server using this thread -

i tried to contact the person that made it but he is not answering and i don’t know php so could someone give me detailed instructions on how to do this?

Just a rough checklist:

  • First you have to make sure your server does actually run and supports PHP and mysql. How to setup and configure a server depends on the used server technology and is not related to Unity or this masterserver solution. If you don’t know how, search elsewhere (google, stackoverflow, PHP forum, Apache forum, whatever-server-you-have-forum)
  • You need to edit all PHP files and insert your mysql server credentials in the first mysql_connect line. (This is a horrible design. Usually you should have a single, seperate file to setup the database connection)
  • You need to create a database on your mysql server (or if you only have a predifined database you can of course only use this one and skip this) and insert the database name in the second line where it reads “mysql_select_db”.
  • In your database you have to create a table named “MasterServer” with those columns:
    • “useNat”
    • “gameType”
    • “gameName”
    • “connectedPlayers”
    • “playerLimit”
    • internalIp"
    • internalPort"
    • “externalIp”
    • “externalPort”
    • “guid”
    • “passwordProtected”
    • “comment”
    • “updated” (should be of type “DateTime”)
  • In Unity you have to attach the “PHPMasterServerConnect” script to a gameobject and setup your domain name / server ip in “masterServerURL”, as well as choosing a gameType and gameName. (keep in mind that in the current setup the gameName has to be unique. Also the masterServerURL need to start with http:// and end with a slash /)
  • Now it works almost the same way the built-in masterserver stuff works. You use the QueryPHPMasterServer method to request a server list for a specific gameType and then you can use PollHostList to retrieve the server list

Note: the table column types aren’t really enforced here. You could use “Text” for most of them. However to prevent exploits some columns should be restricted in length since nobody has an IP address with 200 characters or a playercount number with more than 5 characters :wink:

This is basically what you have to do. However as i just posted on the forum this implementation has some serious security issues and if you plan to use this in a real game those issues should be addressed.

Without actually looking through the PHP source code and whatnot,

You would need a web hosting account. You can pick them up for like $3/mo.

Then you’d upload the files, and in your scripts, call the public location of that script.