- Home /
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 - http://forum.unity3d.com/threads/65551-PHP-Master-Server
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?
I tried that; it doesn't work. Ended up making my own system with PHP and SQL; neither of which I knew anything about to start. The how-to is way beyond what someone could post as an answer here; and it will probably take you months to get working right. If that's something you need to do, there's no shortcut; read lots of already-answered questions on Stack Overflow.
Answer by Bunny83 · Apr 05, 2014 at 11:56 AM
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 ;)
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.
Answer by Cynikal · Apr 05, 2014 at 09:30 AM
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.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Unity networking tutorial? 6 Answers
BCE0049 error with network script 0 Answers